-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
typeahead: Properly handle custom triggers. #14247
base: main
Are you sure you want to change the base?
Conversation
7aad88d
to
46c4c75
Compare
I wonder if this would actually be more maintainable if we just used I would also make the commenting here slightly more verbose, as it's hard for somebody jumping in this code to know what's going on. The variable name |
I guess "selection" is already well explained in the big block comment (which I didn't see in the diff), so disregard that part of my prior comment. |
7a1cf13
to
6adc639
Compare
I was on the fence for using
This is why I added a reference to the issue where I've written a larger write-up. Since the write-up was large enough, I figured it made sense to have it in a rendered markdown format instead of an in-file comment. (#14246). To make sure people stumble on it, I added the comment at the top of the file as well now. |
@@ -352,7 +368,8 @@ | |||
break | |||
|
|||
default: | |||
if (this.trigger_selection(e)) { | |||
if (this.custom_selection_state.should_trigger) { | |||
this.custom_selection_state.should_trigger = false; |
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.
This code is kinda hard to follow. Are we confident that this.custom_selection_state
is always set during a keyup
call? And is the keyCode
in custom_selection_state
used for anything?
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, a keyup event implies that we have already had a keypress event.
6adc639
to
7306c98
Compare
We switch to using keypress event for custom triggers because keyup can be tricky to handle for combo keys. If you press 'shift' + '.', you get > However, we never get the keyup event for '>'. Instead, we get one for '.' and one for 'shift'. If you check the e.key value, depending on whether shift was released first or later, we can get either '.' or '>'. Fixes zulip#14246.
7306c98
to
6643c10
Compare
Heads up @aero31aero, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
4ec3636
to
88b200c
Compare
Fixes #14246.
This fixes an issue in our stream-topic typeahead code where sometimes typing
#den>
wouldn't complete the stream mention.I've added the second commit here to run tests properly.