Skip to content
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

Focus a default button instead of a close button in dialogs #1714

Closed
iliana opened this issue Aug 7, 2023 · 4 comments · Fixed by #1715
Closed

Focus a default button instead of a close button in dialogs #1714

iliana opened this issue Aug 7, 2023 · 4 comments · Fixed by #1715
Labels

Comments

@iliana
Copy link
Contributor

iliana commented Aug 7, 2023

image

This is after hitting the instance menu -> Delete; the focus is around the close button but it would make more sense to focus a default button.

This is a particularly useful example where the default focus should absolutely not be the dangerous red "Confirm" button.

@iliana iliana added the a11y label Aug 7, 2023
@david-crespo
Copy link
Collaborator

Thanks. The analogous issue for the side modal is #440, which we fixed in #930 by deleting the X button (lol), which automatically made the focus go to the thing we wanted. We may be able to do the same thing here.

@benjaminleonard
Copy link
Contributor

I actually re introduced the close button on the pane, and have it absolutely positioned that way it isn’t the first interactive element. A potential solution here too

@zephraph
Copy link
Contributor

zephraph commented Aug 8, 2023

Yeah, we can change the initially focused element so it shouldn't be a problem.

Going back to our previous solution, the easiest thing is just to remove it. I'll play with it a little bit though, I have some ideas.

@benjaminleonard
Copy link
Contributor

Here's the solution for the pane:

{/*
Close button is here at the end so we aren't automatically focusing on it
when the side modal is opened. Positioned in the safe area at the top
*/}
<Dialog.Close
className="absolute right-[var(--content-gutter)] top-10 -m-2 flex rounded p-2 hover:bg-hover"
aria-label="Close"
>
<Close12Icon className="text-secondary" />
</Dialog.Close>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants