Skip to content

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

Closed

Description

@iliana

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.

Activity

  1. david-crespo commented on Aug 8, 2023

    @david-crespo
    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.

  2. benjaminleonard commented on Aug 8, 2023

    @benjaminleonard
    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

  3. just-be-dev commented on Aug 8, 2023

    @just-be-dev
    Contributor

    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.

  4. benjaminleonard commented on Aug 8, 2023

    @benjaminleonard
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions