-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[23543] Multi words zones now work while searching for timezones. #25569
[23543] Multi words zones now work while searching for timezones. #25569
Conversation
I need to add Screenshots/Videos, but I firstly wanted to agree on the desired functionality. This version works as follows:
The only downsides for now are that " @fedirjh Would you say that it's ok as is, or would you want me to make some changes? If so, please tell me what changes. I'll come back with a potential fix & a list of any new downside. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments about the code.
The only downsides for now are that "IsleOfMan" dows not work, and that "East I" shows "US/East-Indiana" at the end of the list. I've tried some changes, but I seem to lose some other functionality by fixing these.
@DanutGavrus Let's use the same regex in the linked proposal, I left a suggestion about normalizing the searchText
and I think that will resolve those issues, just let's make sure to use the right regex .replace(/[^a-z0-9\+\-\/]/g, '')
for the timezone names.
setTimezoneOptions(_.filter(allTimezones.current, (tz) => tz.text.toLowerCase().includes(searchText.trim().toLowerCase()))); | ||
setTimezoneOptions(_.filter(allTimezones.current, (tz) => { | ||
let shouldShow = true; | ||
searchText.toLowerCase().replace(/[^a-z0-9]/g, ' ').split(' ').forEach((word) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can sanitize the searchText before checking :
const searchWords = searchText.toLowerCase().replace(/[^a-z0-9\+\-\s+/]/g, '').split(/\s+/);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep the current regex, this won't be needed, otherwise, I'll update as suggested.
if (tz.text.toLowerCase().replace(/[^a-z0-9]/g, ' ').indexOf(word) < 0) shouldShow = false; | ||
}) | ||
return shouldShow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a lint here.
Can't we use Array.prototype.every()
instead of .forEach
, I think this will simplify the code and make it more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run npm run prettier
, fixed several lint
issues & used Array.prototype.every()
instead of .forEach
.
@fedirjh Based on the review comments, I think this will be the new regex(not the final code, just quickly testing the regex): const searchWords = searchText.toLowerCase().replace(/[^a-z0-9\+\-\s+/]/g, '').split(/\s+/);
searchWords.forEach((word) => {
if (tz.text.toLowerCase().replace(/[^a-z0-9\+\-\/]/g, '').indexOf(word) < 0) shouldShow = false;
})
If my comparison is right, we gain "IsleOfMan" for "Eur/Isl", and "the result is shown at the end of the list for some searches issue" persists. I think the last issue is not very big, inserting 1 more letter eventually shows the result at the top. What would you say? |
@fedirjh Isn't this regex: const searchWords = searchText.toLowerCase().replace(/[^a-z0-9]/g, ' ').split(' ');
searchWords.forEach((word) => {
if (tz.text.toLowerCase().replace(/[^a-z0-9]/g, ' ').indexOf(word) < 0) shouldShow = false;
}) Simpler, more future proof, and with almost the same functionality? We don't exactly specify the special characters(+, -, /) here, maybe some new ones will appear in the future. Only diff in functionality is that "IsleOfMan" does not work and "Eur/Isl" does. Personally, I think I'd prefer this, but let me know which one you want to keep & I'll make a new commit. Thanks! |
@fedirjh Added Web recording for easier understanding of the current changes. |
Hey @DanutGavrus, it appears that we've made updates to the Timezone list in this PR #24446. Some timezones, such as
I don't strongly agree with that. If we were to update the timezone list in the future to include timezones like |
@fedirjh Yes, that PR kind of simplified the timezones list.
It will still show the GMT +1
GMT -1
GMT 1 If the priority issue is to be resolved, I do agree with you, it's not future proof enough. It will be capable to show the results, but will have small problems in prioritizing them, especially for those with special characters. Same is happening in the present, but it's simply resolved by entering one more letter, as seen now for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, left small improvement
searchText | ||
.toLowerCase() | ||
.replace(/[^a-z0-9]/g, ' ') | ||
.split(' '), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
searchText | |
.toLowerCase() | |
.replace(/[^a-z0-9]/g, ' ') | |
.split(' '), | |
searchText.toLowerCase().match(/[a-z0-9]+/g) || [] |
This can be simplified, Can we move to a local const to avoid repeating the same normalization process multiple times within the filter loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yees, of course! Hope I got it right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, It is still included in the filter loop, and should be moved outside the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 Sorry about that... Should be ok now
Reviewer Checklist
Screenshots/Videos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me and tests well.
🎀 👀 🎀 C+ reviewed
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/bondydaa in version: 1.3.59-0 🚀
|
🚀 Deployed to staging by https://github.com/bondydaa in version: 1.3.60-0 🚀
|
🚀 Deployed to staging by https://github.com/bondydaa in version: 1.3.60-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.59-5 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.60-3 🚀
|
Details
Improved search functionality on the select timezone page.
Fixed Issues
$ #23543
PROPOSAL: #23543 (comment)
Tests
Same as QA Steps.
Offline tests
Same as QA Steps.
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
timezone_search.mp4
Mobile Web - Chrome
android_chrome.mp4
Mobile Web - Safari
Desktop
iOS
Android
android_native.mp4