-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 throttle for emoji picker web #23846
Conversation
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Tried it, lgtm! :) |
@@ -43,6 +44,7 @@ const defaultProps = { | |||
forwardedRef: () => {}, | |||
preferredSkinTone: CONST.EMOJI_DEFAULT_SKIN_TONE, | |||
}; | |||
const throttleTime = Browser.isMobile() ? 200 : 50; |
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.
Browser.isMobile
involves mWeb as well. So you meant 50 on web/desktop, 200 on native/mWeb?
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.
Yes, the idea was to use the smallest timeout for more powerful web/desktop machines and slightly decrease it (from 300 to 200) for mobile devices
@@ -75,7 +77,7 @@ class EmojiPickerMenu extends Component { | |||
// prevent auto focus when open picker for mobile device | |||
this.shouldFocusInputOnScreenFocus = canFocusInputOnScreenFocus(); | |||
|
|||
this.filterEmojis = _.debounce(this.filterEmojis.bind(this), 300); | |||
this.filterEmojis = _.throttle(this.filterEmojis.bind(this), throttleTime); |
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.
What's the advantage of throttle vs debounce here?
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 used throttle because it invokes a function at specified intervals, so even if we type fast, it would still be called every 50/200 ms. With debounce, we would wait for 50/200 ms after the last user input before invoking the function. Hence, there were instances when users typed quickly and didn't see the immediate result.
@aimane-chnaif does it work for you? |
debounce-50.movdebounce-300.movthrottle-50.movthrottle-300.mov |
@perunt I think we should use debounce. i.e. when type |
The main issue was being unable to see changes from the input while typing. That's why we need to do a call at the end of a specific time period (throttle) instead of after a certain period following the last keypress (debounce). We could consider extending these periods. Currently, on your machine, it's set to 50ms. I think this is okay since it's not a mobile device, and even on an older laptop, it shouldn't make the app appear laggy. So, what we can do here:
Have you tested it on a mobile device? How does it feel there(it uses 200ms)? |
@aimane-chnaif, what do you think about these options? |
@aimane-chnaif, what is the future of this PR? |
@stitesExpensify , sorry for disturbing you over such minor stuff, but it would be great if you could either merge it or close it. Wdyt? |
If we are fine with this, we can merge with throttle solution |
It depends on how fast you are typing.
It would be called once, everything above 200ms will cause a new invocation. |
Ah sorry @perunt I wasn't assigned as a reviewer so I didn't know this PR existed. I don't see any downside to merging this do you @aimane-chnaif ? If not could you please do the checklist and we will get this closed out? |
All's good, I just don't want to leave any PR hanging |
Please merge main. I will checklist shortly |
done |
@aimane-chnaif, did you have time for it? I just want merge or close it. |
Sorry for delay |
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopiOSAndroid |
✋ 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/stitesExpensify in version: 1.3.86-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.86-5 🚀
|
Details
Fixed Issues
$ #21055 (comment)
PROPOSAL: #21055 (comment)
Tests
Offline tests
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
After.mov
Mobile Web - Chrome
telegram-cloud-document-2-5341759699161197574.mp4
Mobile Web - Safari
Desktop
iOS
Android