-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(overflow-menu): improve overall a11y #1115
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bdd070e
fix(overflow-menu): improve overall a11y
tw15egan 30a0949
fix(overflow-menu): prevent fewer defaults
tw15egan 0c3ddb2
Merge branch 'master' into overflow-a11y
tw15egan c7b5770
fix(overflow-menu): update logic
917081c
fix(overflow-menu): add comment
4dbaa30
Merge branch 'master' into overflow-a11y
tw15egan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
<div data-overflow-menu tabindex="0" aria-label="Overflow menu description" class="bx--overflow-menu"> | ||
<svg class="bx--overflow-menu__icon" width="3" height="15" viewBox="0 0 3 15"> | ||
<div data-overflow-menu tabindex="0" aria-label="Overflow" class="bx--overflow-menu" role="button" aria-haspopup="true" | ||
aria-expanded="false"> | ||
<svg aria-hidden="true" class="bx--overflow-menu__icon" width="3" height="15" viewBox="0 0 3 15"> | ||
<g fill-rule="evenodd"> | ||
<circle cx="1.5" cy="1.5" r="1.5" /> | ||
<circle cx="1.5" cy="7.5" r="1.5" /> | ||
<circle cx="1.5" cy="13.5" r="1.5" /> | ||
</g> | ||
</svg> | ||
<ul class="bx--overflow-menu-options" tabindex="-1" data-floating-menu-direction="{{direction}}"> | ||
<ul class="bx--overflow-menu-options" tabindex="-1" role="menu" aria-label="Overflow" data-floating-menu-direction="{{direction}}"> | ||
{{#each items}} | ||
<li class="bx--overflow-menu-options__option{{#if disabled}} bx--overflow-menu-options__option--disabled{{/if}}{{#if danger}} bx--overflow-menu-options__option--danger{{/if}}"> | ||
<button class="bx--overflow-menu-options__btn"{{#if title}} title="{{title}}"{{/if}}{{#if primaryFocus}} data-floating-menu-primary-focus{{/if}}{{#if disabled}} tabindex="-1"{{/if}}>{{label}}</button> | ||
</li> | ||
<li class="bx--overflow-menu-options__option{{#if disabled}} bx--overflow-menu-options__option--disabled{{/if}}{{#if danger}} bx--overflow-menu-options__option--danger{{/if}}" | ||
role="presentation"> | ||
<button class="bx--overflow-menu-options__btn" role="menuitem" {{#if title}} title="{{title}}" {{/if}} | ||
{{#if primaryFocus}} data-floating-menu-primary-focus{{/if}}{{#if disabled}} tabindex="-1" {{/if}}>{{label}}</button> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
</div> | ||
|
||
<div data-overflow-menu tabindex="0" aria-label="Overflow menu description" class="bx--overflow-menu"> | ||
<svg class="bx--overflow-menu__icon" width="3" height="15" viewBox="0 0 3 15"> | ||
<div data-overflow-menu tabindex="0" aria-label="Overflow" class="bx--overflow-menu" role="button" aria-haspopup="true" | ||
aria-expanded="false"> | ||
<svg aria-hidden="true" class="bx--overflow-menu__icon" width="3" height="15" viewBox="0 0 3 15"> | ||
<g fill-rule="evenodd"> | ||
<circle cx="1.5" cy="1.5" r="1.5" /> | ||
<circle cx="1.5" cy="7.5" r="1.5" /> | ||
<circle cx="1.5" cy="13.5" r="1.5" /> | ||
</g> | ||
</svg> | ||
<ul class="bx--overflow-menu-options bx--overflow-menu--flip" tabindex="-1" data-floating-menu-direction="{{direction}}"> | ||
<ul class="bx--overflow-menu-options bx--overflow-menu--flip" tabindex="-1" data-floating-menu-direction="{{direction}}" | ||
role="menu" aria-label="Overflow"> | ||
{{#each items}} | ||
<li class="bx--overflow-menu-options__option{{#if disabled}} bx--overflow-menu-options__option--disabled{{/if}}{{#if danger}} bx--overflow-menu-options__option--danger{{/if}}"> | ||
<button class="bx--overflow-menu-options__btn"{{#if title}} title="{{title}}"{{/if}}{{#if primaryFocus}} data-floating-menu-primary-focus{{/if}}{{#if disabled}} tabindex="-1"{{/if}}>{{label}}</button> | ||
</li> | ||
<li class="bx--overflow-menu-options__option{{#if disabled}} bx--overflow-menu-options__option--disabled{{/if}}{{#if danger}} bx--overflow-menu-options__option--danger{{/if}}" | ||
role="presentation"> | ||
<button class="bx--overflow-menu-options__btn" role="menuitem" {{#if title}} title="{{title}}" {{/if}} | ||
{{#if primaryFocus}} data-floating-menu-primary-focus{{/if}}{{#if disabled}} tabindex="-1" {{/if}}>{{label}}</button> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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 here is for preventing link from being followed. Did you find a new condition where event's default behavior should be prevented?
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 was running into issues when trying to open the menu with the enter key. Perhaps I should I only prevent that if the key === enter?
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.
Let me know if this is a better solution
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.
Thanks @tw15egan for the background and the suggestion! What I saw is that the change from
keypress
tokeydown
caused the overflow menu to be open (and thus focus moving to the overflow menu item) in the middle of the keystroke (of enter key). When user finishes the keystroke, thekeypress
event fires on the overflow menu item given it's a<button>
and now has focus.One way to get around with this is what you suggested. Great to have above finding as comments so that future maintainers/consumers can figure out why, if we go with this approach.
Another approach to address this is below, which directly removes the weird behavior described above, and thus reduces possibility of future issues (esp. wrt browser compatibility).
Don't hesitate to ping me if you have any questions/concerns. Thanks!
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.
@asudoh made the changes, but still found the need to prevent default when the space key is pressed (https://github.com/IBM/carbon-components/pull/1115/files#diff-cdb22c353cb80d123893d9f188477d1bR191) to prevent the screen from jumping down
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.
Thanks alot @tw15egan! Could you add a comment to describing
32
key default prevention is for preventing screen from jumping down? I think this PR is good to go once it happens - Thanks!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.
Added the comment in, going to merge it! 😄 Thanks for helping out