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

Search Regex Issue on Special Characters #53

Closed
DarkcoderSe opened this issue Nov 28, 2023 · 3 comments · Fixed by #54
Closed

Search Regex Issue on Special Characters #53

DarkcoderSe opened this issue Nov 28, 2023 · 3 comments · Fixed by #54
Labels
bug Something isn't working

Comments

@DarkcoderSe
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

The search was not working properly, it was giving error when search special characters, so I fixed it and here's the solution

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-input-select/src/index.tsx b/node_modules/react-native-input-select/src/index.tsx
index 615ab0f..bfe882c 100644
--- a/node_modules/react-native-input-select/src/index.tsx
+++ b/node_modules/react-native-input-select/src/index.tsx
@@ -225,10 +225,13 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
   /*===========================================
    * Search
    *==========================================*/
+  const escapeRegExp = (text: string) => {
+    return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+  };
   const onSearch = (value: string) => {
     setSearchValue(value);
 
-    let searchText = value.toString().toLocaleLowerCase().trim();
+    let searchText = escapeRegExp(value).toLocaleLowerCase().trim();
 
     const regexFilter = new RegExp(searchText, 'i');
 

This issue body was partially generated by patch-package.

@azeezat azeezat mentioned this issue Nov 30, 2023
14 tasks
@azeezat
Copy link
Owner

azeezat commented Nov 30, 2023

@DarkcoderSe Thank you for reporting this issue!

@azeezat azeezat added the bug Something isn't working label Nov 30, 2023
@DarkcoderSe
Copy link
Author

hope it will be merged soon!

@azeezat
Copy link
Owner

azeezat commented Dec 1, 2023

hope it will be merged soon!

Yes! Thanks again. The fix has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants