-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Board switcher keyboard shortcut navigation #3242
Conversation
Similar to Cmd/Ctrl + K, need to do it via native event listener when focused on an <input>.
@@ -81,6 +85,7 @@ const BoardSwitcherDialog = (props: Props): JSX.Element => { | |||
title={title} | |||
subTitle={subTitle} | |||
searchHandler={searchHandler} | |||
refs={refs} |
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.
All this refs passings looks a bit convoluted to me. Couldn't it be something like an state at this level with the selected id? and an onSelect callback or something like that?
I always find passing refs down the components really hard to track.
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 agree, it wasn't as straightforward as I was expecting it to be. My reasoning for using ref
s was it let me use the native .focus()
and .click()
methods on the underlying native elements.
Since the parent component (this) defines the search handler which returns the JSX components and passes that definition into the child component which calls it and does the rendering, it seemed to make sense to define the ref
s in the parent so the child could use the native methods I mentioned above. onSelect
did come to mind, but it's not available for all elements, only <input>
and <textarea>
.
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.
Ok, what I meant is. move the selected
state to the BoardSwitcherDialog
component, update the selected
state using a callback that is passed to the SearchDialog component, and then, you can use a useEffect
call to update the focus on every selected
change. The syntethic click, is not going to be needed, because you are already there, and you have access to the selectBoard
function. You are going to still need the refs, but you are not passing them around that is what makes it more confusing.
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.
@jespino Refactored it as requested and while I agree passing refs
as props is confusing, I'm not positive trading passing the selected
state is less confusing. Additionally, needed to move the keyboard event listeners around. I believe the functionality is the same, but I still prefer my original approach after doing the refactor.
Let me know your thoughts—take care not to merge as the cherrypick label(s) will need to be updated.
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 have some doubts about the approach.
/update-branch |
@jespino friendly ping to re-review when you have time 🙂 |
/update-branch |
/update-branch |
/update-branch |
/update-branch |
/update-branch |
@jespino - Would you review this again? |
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.
It still looks to me a bit complicated code, but at least no passing a list of refs makes it more contained. LGTM
/update-branch |
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.
LGTM 👍
Cherry pick is scheduled. |
Co-authored-by: Mattermod <mattermod@users.noreply.github.com> (cherry picked from commit f241fc1)
Summary
Implements esc/up/down/enter keyboard shortcuts for better navigating the Boards switcher—similar to Channels.
Ticket Link
closes #2755
Screen.Recording.2022-06-16.at.1.29.54.PM.mov