Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Board switcher keyboard shortcut navigation #3242
Changes from 3 commits
f98a958
f877a6e
fbb3bce
b59270a
a371162
12b17bc
c67b6f1
b5dd226
b61247b
0513f33
1aa4dfa
1f54162
8205838
407fe98
94bdacb
c422f15
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 theBoardSwitcherDialog
component, update theselected
state using a callback that is passed to the SearchDialog component, and then, you can use auseEffect
call to update the focus on everyselected
change. The syntethic click, is not going to be needed, because you are already there, and you have access to theselectBoard
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 theselected
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.