wix / react-native-ui-lib

UI Components Library for React Native

Home Page:https://wix.github.io/react-native-ui-lib/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat request: Ability to disable filter function in picker

DrZoidberg09 opened this issue Β· comments

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-native-ui-lib@7.15.0 for the project I'm working on.

I want to use the picker component for a dynamic backend. In this case I use it for address research. However, if it is used as search function, the filtering will lead to a wrong list. Example: I search for "Street, City" and the backend will give the proper address like: "City, Street, zip code, Country". However, this might not match the search string and hence the list will be empty.

Therefore, it would be best to add prop to disable the filtering function.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-ui-lib/src/components/picker/helpers/usePickerSearch.js b/node_modules/react-native-ui-lib/src/components/picker/helpers/usePickerSearch.js
index 284ff32..a3f4bff 100644
--- a/node_modules/react-native-ui-lib/src/components/picker/helpers/usePickerSearch.js
+++ b/node_modules/react-native-ui-lib/src/components/picker/helpers/usePickerSearch.js
@@ -7,11 +7,12 @@ const usePickerSearch = props => {
     showSearch,
     onSearchChange,
     children,
-    getItemLabel
+    getItemLabel,
+    noFilter
   } = props;
   const [searchValue, setSearchValue] = useState('');
   const filteredChildren = useMemo(() => {
-    if (showSearch && !_isEmpty(searchValue)) {
+    if (showSearch && noFilter && !_isEmpty(searchValue)) {
       // @ts-expect-error need to fix children type
       return _filter(children, child => {
         // @ts-expect-error need to fix children type to be based on PickerItemProps
diff --git a/node_modules/react-native-ui-lib/src/components/picker/index.js b/node_modules/react-native-ui-lib/src/components/picker/index.js
index d023ed7..fc7edb4 100644
--- a/node_modules/react-native-ui-lib/src/components/picker/index.js
+++ b/node_modules/react-native-ui-lib/src/components/picker/index.js
@@ -37,6 +37,7 @@ const Picker = React.forwardRef((props, ref) => {
     fieldType = PickerFieldTypes.form,
     selectionLimit,
     showSearch,
+    noFilter,
     searchStyle,
     searchPlaceholder,
     renderCustomSearch,

This issue body was partially generated by patch-package.