-
Notifications
You must be signed in to change notification settings - Fork 81
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
Kdropdown keyboard navigation #185
Kdropdown keyboard navigation #185
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 code looks good aside from the console.log
@radinamatic might have some more insights here on the a11y.
When I got focused into the first element of the dropdown, I tried using the arrow keys to navigate the menu items which scrolled the whole page and I realized you can only tab through the children.
I did some digging and found this: https://www.w3.org/TR/wai-aria-practices/examples/listbox/listbox-collapsible.html - if you scroll down you see some specs for Keyboard Navigation.
Perhaps the use case there is slightly different than ours? In any case - I'll let @radinamatic weigh in on that aspect.
@nucleogenesis - thanks for your notes! You are right about the arrow keys and not the tab. I had read some resources saying either was fine, but I think it's a better idea to go with the w3 standard. I'll make those changes today or tomorrow and hopefully get this wrapped up before we move into all-product sprints 😊 |
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.
Approving from the design side - the behaviors you implemented make a lot of sense, and so does the highlight itself
@nucleogenesis - I made some changes to the code since you last reviewed. One making sure the arrow keys worked and two adding a |
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.
With @indirectlylit's note about the CSS and the fiddly a11y tab/keyboard navigation stuff I noted both resolved this should be good to go, thanks @marcellamaki !
// identify the menu state and length | ||
const popover = this.$refs.popover.$el; | ||
const menuElements = this.$refs.menu.$el.querySelector('div').children; | ||
const lastChild = menuElements[menuElements.length - 1]; |
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.
When we're on the lastChild and hit tab (keycode 9) then the focus outline is lost altogether and I'm not sure where it is. The menu stays open as well.
On that W3 link I shared in my previous comment, if you keyboard navigate to the dropdown (you'll have to eyeball it because it doesn't show a focus indicator on that site) - but if you hit space to open it, arrows to navigate within it, and then hit tab - the tab key moves the focus to the next element in the DOM.
So the listed items in the drop-down should not be a part of the tab navigation.
…ions, but rather advances to next element in tab order
f32776b
to
07ca4ef
Compare
…ter manage keyboard event focus by default on interactive elements, while allowing explicit support for keyboard navigation
I've made some changes in this PR that were not changes when I started it, but now are reverting other changes that have been made in the interim around focus and keyboard navigation. Would especially appreciate review from @sairina and @MisRob in regards to these changes, as it essentially undid some recent changes. For context and the thought process:
General approach to changes:
Outcomes of implementation: NOT SOLVED BY THIS The user profile dropdown menu in the top right corner does not use this same style of menu. It is currently navigable with tab keys, which might be confusing to users... However it is being removed in 0.16. Worth discussing whether there should be a follow up issue to change this... I think it might be a low lift and the consistency might be beneficial? |
Progress looks very exciting, thank you @marcellamaki! |
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.
Thank you @marcellamaki, this is great work. I've only checked the code so far. To be honest, I don't recall exactly all updates to the tracking input modality script I did and reasons for them but I think that your updates with all background information and comments in this PR make sense overall. Thank you for sharing the WebAIM resource on keyboard testing, that's very helpful. I learned a lot from the discussion and work in this PR.
I left some minor comments, neither of them is blocking.
The only thing that needs to be resolved is kolibri-tools upgrade. I saw that you posted a message on Slack about it so I responded there with some issues I experienced.
57a48ab
to
f60af80
Compare
document.body.setAttribute('modality', 'keyboard'); | ||
} else { | ||
globalThemeState.inputModality = null; | ||
document.body.setAttribute('modality', ''); |
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.
See learningequality/kolibri#4822 and learningequality/kolibri#4847 for some historical context on how the code got into its current state.
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.
One thing still missing for the body modality attribute.
Description
This PR adds tab navigability for KDropdownModal. Currently, a user cannot use keyboard navigation to enter into the dropdown.
Issue addressed
Fixes #178
Before/after screenshots
BEFORE
AFTER
Steps to test
Comments
Any feedback for general code improvement (and if I'm using some of the existing KDS patterns correctly) or about how this affects other components that I might not be thinking of would be very helpful.
Also, @jtamiace / @khangmach, I am not sure if there is already a design convention for the focus on menu items. I did review the existing docs but know they're a WIP and it's possible you have some work on this that I'm just unaware of. If you have design feedback or recommendations of how I can improve this, please let me know! So far, I just tried to adapt existing patterns and styles, but I'm sure there is room for improvement.