-
Notifications
You must be signed in to change notification settings - Fork 15
fix: add a props to make the menu focus the trigger when closing #355
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
base: main
Are you sure you want to change the base?
Conversation
Deploying compound-web with
|
Latest commit: |
8748045
|
Status: | ✅ Deploy successful! |
Preview URL: | https://6bd3b04d.compound-web.pages.dev |
Branch Preview URL: | https://florianduros-focus-menu.compound-web.pages.dev |
@@ -123,9 +129,11 @@ export const Menu: FC<Props> = ({ | |||
align={align} | |||
sideOffset={8} | |||
onCloseAutoFocus={(event) => { | |||
// https://www.radix-ui.com/primitives/docs/components/dropdown-menu#content => onCloseAutoFocus | |||
// Prevent the default behavior of focusing the trigger when the menu closes |
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.
Returning focus is the wai-aria specified behaviour, when would we want focusTriggerOnClose=false?
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 was for the case of TAC: #147
Maybe it make more sense to put the props to true by default
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.
Looks like the TAC is not accessible then, I just tried in EW and closing the tac resets my tab position to the start of the page which is very much a no-no. The tooltip showing again is a nit at best vs a major accessibility failure. Might want to special-case the focus return for keyboard accessibility vs pointer interaction if hiding the tooltip on close is important, or a way to not show the tooltip on menu close somehow.
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 succinct terms, I think focusTriggerOnClose
is misled and needs to be forced to true generally, including for the TAC.
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.
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.
Okay, I'll revert then #147
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 as a safe interim solution changing it to not apply for keyboard interaction might be saner, to not regress the general UX, the more intricate solution can always come 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.
Maybe I'm wrong but radix doesn't offer this kind of precision in its event. It is firing a custom event without info if it's from a keyboard or pointer interaction (for both escape or menu item selection)
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.
That's daft. radix-ui/primitives#2248 (comment) is the issue with a potential workaround
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 read the issue and I think it's different of our use case. We don't have a tooltip inside a popover but on the popover trigger. Stopping propagation makes the first row of the tac unfocused, the user can't interact with it.
I don't see any good solution where UX and a11y are ok. I'll remove the #147 to make the TAC accessible.
Due to #147
We want to have the focus to be back on the trigger when the menu closes.