pankod / react-native-picker-modal-view

An unified React Native Picker Modal component for iOS and Android.
204 stars 55 forks source link

Items being incorrectly filtered out #94

Open leemcmullen opened 2 years ago

leemcmullen commented 2 years ago

I've discovered an issue where lots of items are incorrectly being filtered out of the list to select from, even though the search input is empty. This is happening on an Android emulator on Windows, with RN 0.66.3 and using Hermes.

I tracked it down to the filter call in the Helpers/index.ts file (https://github.com/pankod/react-native-picker-modal-view/blob/master/src/Helpers/index.ts#L50).

The filter function calls searchText.toLocaleLowerCase() as part of the process to filter out any items which don't match the search text. I tried to console.log the result of the .toLocaleLowerCase() call but it was returning the following error: "string length exceeds limit".

That was very confusing given that searchText was an empty string.

I eventually tracked the source of the issue down to an obscure Hermes bug where an empty string being passed to .toLocaleLowerCase() was not in fact returning an empty string but was instead "reading garbage UTF-16 codepoints off the stack": https://github.com/facebook/hermes/commit/54c878838c5776eb0ce7ab2d0b06804d5141218c

I'm just adding this here in case anyone else comes across the same thing and wonders why the full list is not being rendered.