-
Notifications
You must be signed in to change notification settings - Fork 361
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
Menubar examples: Make mouse behaviors and parent menu item appearanc… #593
Conversation
…e change triggers more consistent with desktop conventions w3c#408 This commit fixes the menubar-2 example. It ensures the following behavior: - open menus stay open on mouseout - remove timeouts that close menu on mouseout - close menu when user: - clicks outside menu - clicks again on menubar item - clicks on menu item in menu - types tab or shift+tab - types space or enter on menu item (but not for space on radio/checkbox) - hovers over another menubar item (other menu opens) - menubar item retains its activated appearance while its menu is open Details of the code changes: - deleted hasFocus and hasHover state booleans because they are no longer needed - added popupMenu.isOpen() which checks for aria-expanded=true on the corresponding menubar item's DOM element - added ESC key handling on menubar items (closes menu if open) - clicking on menubar item opens menu, clicking again on same menubar item closes it - make sure browser doesn't scroll when clicking on menubar item (default behavior for clicking on link) - removed focus, blur, and mouseout event handling and timeouts from menubar items - removed focus, blur, mouseover, and mouseout event handling and timeouts from popup menu items - added focusout on menubar item and popup menu item to close menu if focus will be going outside of the menubar - if a menu is open, then hovering over a different menubar item opens its menu instead - removed check for anchor element children of menubar items (was probably an artefact from a previous implementation) - removed mouseover and mouseout events from popup menu - removed 'force' parameter from popup menu close() function - deleted some vars that were declared but not used, or were declared twice - fixed a few comments that didn't quite match the code - declared some vars as local that were declared as global (i.e. without var keyword) but did not need to be - removed some redundant checks, i.e. while (e) { if (e ...) } - changed != to !== and == to === where appropriate - removed css for hovering over menubar item (not needed because hovering focuses menubar item)
@annabbott, @sh0ji, @shirsha, @jongund, You can view/test the result of these changes in the RawGit view of the editor menubar example page in Carolyn's repo. For your convenience, here is the current published version of the editor menubar on w3/tr. @carmacleod, thank you very, very much for this contribution. It's a big change. So, I am having several people look closely before commiting to master. With multiple reviewers, there could be some churn in the comments. Please do not make changes unless we have clear agreement that a change is needed. |
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.
- Windows Firefox/JAWS:
- All kb commands work as described
- All roles, states, and properties being set/changed as described.
- Windows Chrome/JAWS:
- All kb commands work as described
- All roles, states, and properties being set/changed as described.
Note: above tests are of the example code, not the screen reader.
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 tested with VoiceOver with Safari and Firefox on OSX and it works
I tested with NVDA with Firefox and Chrome on Windows 10 and it works.
The only question I have is when you select a regular menuitem when a screen reader is running, the popup menu closes and moves focus back to the menubar menuitem. The popup menu does not close when testing keyboard support without a screen reader, the popup menu just stays open.
The updated mouse behaviors are more inline with OS menu mouse behaviors.
Tested with Win10/FF ESR 52.6.0/JAWS 2018 (build 1712.10 ILM) |
Tested with Win10/FF ESR 52.6.0/kbd only (no screen reader) |
Tested with Win10/Chrome Version 64.0.3282.140 (Official Build) (64-bit)/JAWS 2018 (build 1712.10 ILM) This is specific to Chrome. It is announced correctly on FF. All good! |
Tested with Win10/Chrome Version 64.0.3282.140 (Official Build) (64-bit)/kbd only (no screen reader) Note: I was unable to replicate Jon's kbd-only test results. |
My testing is complete. |
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.
Great stuff! Lots of good changes in this PR.
Verified that it works as expected in Chrome and Firefox with NVDA on Windows 10. I'll test on macOS tomorrow, but I don't think that needs to hold up this review.
My only issue is that hovering over a menuitem
element on the menubar
now also focuses the menuitem
element. I've never encountered a widget where hovering causes a change of focus. My expectation is that hovering might cause some visual change to let the user know that the item is interactive, but that any change of context should be initiated by the user more deliberately (click or tab to focus). This is kind of similar to WCAG SC 3.2.1, except hovering is causing the change of context.
I wasn't able to replicate the keyboard issue described by @jongund.
As a follow-up, I'd actually argue that the screen reader experience is better than the keyboard or mouse experience on this one now, though not because of changes made in this PR. We may want to review the visual design for that reason. Specifically:
|
Thank-you all so much for your comments and testing! I have a few replies:
|
@carmacleod, thank you for opening the chromium bug!! @carmacleod commented:
We would like a commit added to this pull request for this focus on hover problem before merging.
This would be a separate issue and PR. I opened issue #605.
I agree. But, in this particular case, the group labels are particularly useful because they provide a screen reader analog to the visual separation. Remember that separators are not announced. That is generally fine since most of the time separators are there to help with visual scanning as opposed to communicating a specific intent. Here, labels like "none" aren't particularly good unless they are accompanied by the group label. And, btw, NVDA is the only screen reader that reads the group labels when they should be read. I am guessing that sighted users can easily dicern "none" in the text decoration group means "no text decoration" because of its proximity. If that is not the case, then maybe that label should be changed to "No decoration". On the other hand, the visual separation of colors is surely adequate and there is no need for a visual label of "text color". I didn't open a new issue for this aspect of the visual design; I am not confident there is an issue. I did note that we didn't document the use of aria-label on the groups so I created issue #606, which I can fix later after we merge. |
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 issue to fix before merging raised by @sh0ji: hover should not move focus.
…ot give it focus (unless the menubar already has focus - see issue w3c#408 comment for explanation) Details of change: - added "focus" class on the menubar as a styling hook to not show hover style if menubar is focussed - added focusin handling to menubar, and moved focusout handling up to menubar (formerly in menubar item and menu item) to support .focus styling hook - changed menubar's setFocusToItem function to not change focus or tabindex on mouse hover, unless menubar already has focus - added mouseover handling to menuitem to give focus to hovered item in open menu - removed unused flag parameter from 2 functions
…another menu, then mouse click without moving first should close open menu first before opening. issue w3c#408
I'm generally okay with the current implementation, which I'll summarize: when not active, hover either does nothing or provides visual feedback (it currently does this by inverting colors and changing to a pointer cursor), but it does not focus anything until the user activates the menubar through either a focus or click action. Once the user activates the menubar, focus follows the hovered item. This is similar to how operating system menus work--macOS actually does nothing on hover until the user activates the menubar, but otherwise works identically to the current example. The pattern of a hover event triggering a focus event is nearly unheard of on the web, though. And I argue that it's similar to SC 3.2.1 in WCAG, but with the |
@mcking65 commented:
While I agree for our specific case, I don't want to assume this for the general case. There's a cognitive load associated with looking at a grouping of items and determining how they're related. That cognitive load can be mitigated by having an explicit label for the group, regardless of how the user experiences it. On a similar note, if we're okay with the cognitive load required to understand the grouping for sighted users, does it need a label at all? I don't have answers for this. I just wanted to point out that the screen reader user has access to explicit information for a couple items that are only ever implicit for sighted users. |
Good news: the chromium "menu 1 of 1" bug is fixed, and will be in Chrome 67. |
This latest commit does not change any behavior; I only changed css. (and a comment) Please don't worry about focus following hover inside an open menu, because when the menu closes, focus goes back to the parent menuitem anyhow. So there's no possibility of loss of context, because the user never left the context of the menubar. Note again that focus does not follow hover unless the menubar or one of its menus already has focus (which can only happen after the user explicitly clicks on or tabs into the menubar). We all agree that this is how application menus work on the desktop, and as @katiehockman pointed out in #598, this is also how Google Docs chose to implement their web application menus. |
…der to focused menubar item.
Latest fixes now available on rawgit. Please try and let me know. |
I don't think I'm explaining this very well, somehow. :) Please try it again, and do the following test to reassure yourself that all is well:
It is this last point that has some of you worried because the implementation at that point does involve moving focus on hover. However, I will argue that this implementation detail results in a superior user experience for the following reasons:
|
@carmacleod This looks great, and I'm in agreement about the "move focus on hover after entering the menubar." Thanks for all your patience on this! @mcking65 This can be merged as far as I'm concerned. |
…e change triggers more consistent with desktop conventions #408
This commit fixes the menubar-2 example.
It ensures the following behavior:
Details of the code changes: