Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat request: Ability to disable filter function in picker #2914

Open
DrZoidberg09 opened this issue Jan 28, 2024 · 0 comments
Open

feat request: Ability to disable filter function in picker #2914

DrZoidberg09 opened this issue Jan 28, 2024 · 0 comments

Comments

@DrZoidberg09
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants