Conversation
| * - collapsing whitespaces | ||
| * - trimming | ||
| */ | ||
| function normalize(text: string): string { |
There was a problem hiding this comment.
Can this reuse some of the other normalize functions? Like for diacritics?
There was a problem hiding this comment.
It does reuse sanitizeString and removeInvisibleCharacters.
I agree there's kind of a lot of overlap here that should probably be cleaned up at some point. Don't really want to do it in the scope of a deploy blocker fix though. I feel like long-term we'll want a really fast fuzzy matcher that handles normalization internally.
There was a problem hiding this comment.
Curious why sanitizeString is being used, as it caused a bug #61752
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
Make search bars work with spaces (cherry picked from commit 23aa17c) (cherry-picked to staging by roryabraham)
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Cherry-picked to staging by https://github.com/roryabraham in version: 9.1.43-3 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
|
🚀 Cherry-picked to staging by https://github.com/roryabraham in version: 9.1.43-5 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.1.44-8 🚀
|
|
|
||
| const filterCategory = useCallback((categoryOption: PolicyOption, searchInput: string) => { | ||
| return !!categoryOption.text?.toLowerCase().includes(searchInput) || !!categoryOption.alternateText?.toLowerCase().includes(searchInput); | ||
| const categoryText = StringUtils.normalize(categoryOption.text?.toLowerCase() ?? ''); |
There was a problem hiding this comment.
Coming from #72615, we should use tokenizedSearch here for better matching result
Explanation of Change
Sometimes strings from the back-end seem to include non-breaking spaces or other invisible characters. We could also see weird results with diacritics and such.
So this PR updates all usages of
useSearchResultsto normalize both the search values and the search term before checking for a match.Fixed Issues
$ #61650
Tests
Precondition:
Offline tests
same as tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov
MacOS: Desktop