From 58903090958ef0e6748e1a523fcf9906d5ecc775 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Sun, 19 Nov 2017 17:09:53 -0800 Subject: [PATCH] Minor bug in random generator for `selection` prop Summary: `.sort()` will sort on the string value by default, so if you generate [18, 8], they will stay in that order. Adding comparer to ensure values are sorted numerically. Found a bug in RNTester. Ran RNTester and confirmed that bug could be reproduced. [IOS][BUGFIX][RNTester] - patch test to implement desired behavior. Closes https://github.com/facebook/react-native/pull/16871 Differential Revision: D6371550 Pulled By: shergin fbshipit-source-id: 84866d1eb02c2be51cd15a60490604d28fa18973 --- RNTester/js/TextInputExample.ios.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RNTester/js/TextInputExample.ios.js b/RNTester/js/TextInputExample.ios.js index 453bc269b9e89e..efb11653391e4a 100644 --- a/RNTester/js/TextInputExample.ios.js +++ b/RNTester/js/TextInputExample.ios.js @@ -284,7 +284,7 @@ class SelectionExample extends React.Component<$FlowFixMeProps, SelectionExample } selectRandom() { - var positions = [this.getRandomPosition(), this.getRandomPosition()].sort(); + var positions = [this.getRandomPosition(), this.getRandomPosition()].sort((a, b) => a - b); this.select(...positions); }