-
Notifications
You must be signed in to change notification settings - Fork 268
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
feat: Add keyboard navigation #225
Conversation
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.
The PR diff size of 25743 lines exceeds the maximum allowed for the inline comments feature.
# Conflicts: # .codeclimate.yml # .prettierrc # src/index.js # src/input/index.js # src/tag/index.js # src/tree-node/index.js # src/tree-node/index.test.js # src/tree/index.js # yarn.lock
@ellinge, help me figure out the merge sequence, please! Ideally, it shouldn't matter, but since we have overlapping PRs, I'm trying to minimize the effort here. What do you say to this order:
|
@mrchief sounds good. Will probably need more tweaking (WCAG) but perhaps it’s better to start off with something than waiting forever for the perfect PR. Haven’t really had the time or energy to do any more tries with actions and the tag-navigation. The good thing is that even if we need to change something with aria or keyboard no one should really rely on them (css selectors or from outside in code I mean). |
Yep & Yep! So I'm gonna start in that order and try to close the PRs. |
# Conflicts: # __snapshots__/src/index.test.js.snap
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. In the interest of time, we can get this merged and have those addressed as future improvements if fixing them takes longer than a few minutes. The regex one, in particular, should be looked upon as once we release it as such, it sort of creates an expectation and would be harder to pull back in future releases.
if (!showDropdown && (keyboardNavigation.isValidKey(e.key, false) || /^\w$/i.test(e.key))) { | ||
// Triggers open of dropdown and retriggers event | ||
e.persist() | ||
this.handleClick(null, () => this.onKeyboardKeyDown(e)) |
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.
Help me understand why we're doing it this way - especially why we're calling onKeyboardKeyDown
again within the onKeyboardKeyDown
handler.
I believe you're trying to reuse the state setting logic and then react after that logic does its thing? If so, I think it's time to refactor handleClick
.
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 wait for the state to update and retrigger the event to select the first node in the now visible dropdown.
Code Climate has analyzed commit 5edbc88 and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
* feat: Test try a11y in test with axe * fix: Initial commit (non working) * fix: Working keyboard navigation * fix: Backspace only on empty search * fix: Adjust code to check codeclimate * fix: Refactored some parts to utils * fix: Refactored some parts to utils * fix: Code refactoring * fix: Add documentation * fix: Refactor * fix: Refactor * fix: Refactor * fix: Refactor * fix: Refactor * fix: Add to typings * fix: Close on Enter * fix: Refactor * fix: Added test * fix: Added some aria * fix: Add label option * fix: Render until node on pagedown * fix: More tests added and fix pagedown on large search result * fix: Modify output on violations * fix: Code smells * fix: Updated doc and center scrollIntoView, fix hasMore() * fix: Trigger on*-events properly, only open for chars and whitelist * fix: Skip som aria in this branch * fix: Add tests and fix snapshot * fix: Add tests and fix snapshot * fix: Enabled by default * fix: Avoid scroll of whole page, only dropdown * fix: Remember focus during prop updates * fix: Delete unintentional dist-file * fix: Do not select readOnly/disabled * fix: Switch to babel-plugin-transform-runtime instead * fix: Add label to trigger as well * fix: Highlight tag on focus, ad aria-labels * fix: Highlight tag on focus, ad aria-labels * fix: Update snapshots, match default * fix: Allow navigate to disabled/readonly * fix: Code review/smells fixes * fix: Code smell * fix: Code smell * fix: Move to a11y-folder, shared onKeyDown test method * fix: Build error and tabIndex * fix: Set new focus after delete * fix: Code climate * fix: Code climate * fix: Select on tab for simpleSelect * fix: Add more tests * fix: Add prop for setting remove aria-label * fix: Code climate * fix: Add typing for labelRemove * fix: Adjust timeout * style: Bring prettier manually to reduce conflicts * fix: Prettier and removed comment * fix: Added migration guide * fix: Bundle text props * fix: Typing errors * fix: Renamed prop * Revert "fix: Renamed prop" This reverts commit 4145f8c. * Revert "fix: Typing errors" This reverts commit 6aa4beb. * Revert "fix: Bundle text props" This reverts commit 4256ce2. * Revert "fix: Added migration guide" This reverts commit a4fc033. * fix: Validate radioSelect also * fix: Moved around methods * refactor: Separate out test utils from exported ones * refactor: Use ES6 getter instead of custom method for accessing tags
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Work in progress.
Adds keyboard navigation as an option. Inspired by:
https://www.w3.org/TR/wai-aria-practices-1.1/examples/treeview/treeview-1/treeview-1a.html
https://www.w3.org/TR/wai-aria-practices-1.1/examples/combobox/aria1.1pattern/listbox-combo.html
Also have looked at react-select
Also adds a11y-tests with axe. The only violation identified is missing label for seachInput though.
Added possibility to pass label with id which sets aria-labelledby or else aria-label on searchInput.
Added some related aria-attributes based on examples. Probably more needed though. This is mostly covered to handle traversing of nodes with keyboard and not how we should handle tags and actions by keyboard. This is something to start with at least.
Sample up and running here:
https://ellinge.github.io/react-dropdown-tree-select-test/#DevelopTemp-nocheckeddefault
Turned off can be seen here:
https://ellinge.github.io/react-dropdown-tree-select-test/#DevelopTemp-keyboardnavigationoff
Partly addresses #216