-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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(web): keyboard accessible context menus #10017
Conversation
…/accessible-menu-v2
…/accessible-menu-v2
…/accessible-menu-v2
14bd691
to
276a446
Compare
…/accessible-menu-v2
- configurable title - focus management: tab keys, clicks, closing the menu - automatically closing when an option is selected
7365b45
to
a755acc
Compare
…/accessible-menu-v2
e22868e
to
13a4598
Compare
- adjust the aria attributes - intuitive escape key propagation - extract context into its own file
13a4598
to
04b06d2
Compare
2bc383a
to
998376e
Compare
- export selectedColor to prevent unexpected styling - better context function naming
998376e
to
ac51083
Compare
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.
It is a lot of changes. It seems like the list enhancements could have been separated out into a different change set.
export let ariaHasPopup: boolean | undefined = undefined; | ||
export let ariaExpanded: boolean | undefined = undefined; | ||
export let ariaControls: string | undefined = undefined; |
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 think there is an export HTML*Type field you can use to get the actual type for these properties.
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.
In my opinion, I find the syntax for automatically adding the HTML props a little confusing/cumbersome, especially because this CircleIconButton
component has so many props. Here's a similar example:
immich/web/src/lib/components/shared-components/immich-logo.svelte
Lines 13 to 19 in 08426e1
interface $$Props extends HTMLImgAttributes { | |
noText?: boolean; | |
draggable?: boolean; | |
} | |
export let noText = false; | |
export let draggable = false; |
I'm wondering if this would be an easier change to do once we have the new Svelte 5 prop typing? Happy to add the automatic HTML props now if that's preferred.
web/src/lib/components/photos-page/actions/asset-job-actions.svelte
Outdated
Show resolved
Hide resolved
Thank you for the time and feedback, @jrasm91! I agree, the list changes expanded the scope of the PR. I'll revert those and put them into their own Svelte action, which I think would still be helpful to prevent duplicated code between the |
…/accessible-menu-v2
…/accessible-menu-v2, fix merge conflicts
c44ea24
to
ca527af
Compare
- better prop naming for ButtonContextMenu
ca527af
to
bbf8ab5
Compare
319ace8
to
03d1263
Compare
- also: minor cleanup of the context-menu-navigation Svelte action
1404a77
to
fbc373a
Compare
…/accessible-menu-v2
ad9cfad
to
76ae57a
Compare
This is ready for review! I've responded to open feedback and closed the remaining tasks on my list. |
…/accessible-menu-v2
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.
Good work! Thanks Ben!
@ben-basten this PR introduces a bug that makes three dot button still visible after context menu is closed. 2024-06-25.14.22.24.mp4 |
@waclaw66 This is working as designed - focus is on the 3 dot button after the context menu closes, so it stays visible. New in this PR is that focus returns to the button that triggered the context menu when it is closed. This allows keyboard users to regain their previous focus position after interacting with a context menu. The same behavior occurs when a mouse user clicks away from the menu. Test scenario to check this:
I thought this made sense since buttons/links on the screen aren't interactive when clicking away from the context menu. An option we have is to consider disabling this refocus behavior for clicking away. |
@ben-basten That make sense, thanks for detailed explanation as usual. |
Loosing focus and forwarding click event should be consolidated though. Some context menus (asset viewer, face) allow to click outside and forward click event to the target control (e.g. left panel), album menu doesn't allow that. Please check a compare the behaviour. |
Yeah, the albums page is unique because it has a context menu that appears when you right click on the album cover. When I right click on a website on my Mac, the default MacOS context menu doesn't let me click anything behind it until the context menu is dismissed. So, it makes sense to imitate that behavior with our custom right click context menu. However, this behavior doesn't make as much sense when the 3 dots button on the top right of the album cover is clicked, because we already have an established pattern for how that should work everywhere else. The fix here would be to move the 3 dot menu from using the Feel free to pitch out a PR for this, I'm not sure when I'll have time to make this change yet. This can certainly be improved, thanks for calling it out! |
Description
Enable arrow key navigation of dropdown menus. Accessibility features are based on this WCAG "actions menu" pattern:
https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/examples/menu-button-actions-active-descendant/
This also simplifies implementing a
ContextMenu
dropdown, because the implementing component no longer needs to keep track of the dropdown visibility state or position. All of that logic is handled internally within the component.Also in this change:
AssetSelectContextMenu
toButtonContextMenu
, to make the naming more accurately reflect what it doesHow Has This Been Tested?
Verified that options in affected context menus behave as expected:
Screenshots
Example dropdown menu, with the darker selected color.
Expand for screenshot