Skip to content

Autofocus confirmation dialogs (like "Convert to draft") #9247

Open

Description

@fregante

Description

GitHub has a few of these custom dialogs that fail the most basic of UX rules for modals: you can't accept them by pressing space/enter.

Image

The solution would be simple:

  1. detect modal opening
  2. auto-focus "accept" button

The feature would be in the same vein as no-modals and same-page-links, where we improve accessibility and UX by making things work as well as their native counterparts.

It could be named modal-autofocus

Example URLs

refined-github/sandbox#1

Activity

  1. added
    small
    on Apr 23, 2026
  2. fregante commented on Apr 23, 2026

    @fregante
    MemberAuthor

    The dialog displayed in #9200 for example works correctly, the "Keep editing" button is focused, meaning you can press tab, enter to continue. I think it's the wrong button selected, but alas changing it would cause issues here.

  3. fregante commented on May 19, 2026

    @fregante
    MemberAuthor

    Another one:

    Image
  4. fregante commented on May 20, 2026

    @fregante
    MemberAuthor

    Note how they ALL use a different component 😭

  5. SunsetTechuila commented on May 20, 2026

    @SunsetTechuila
    Contributor

    Note how they ALL use a different component 😭

    Is this a big problem? Can we watch for :is(dialog, div[role="dialog"]) primary-button-selector?

  6. SunsetTechuila commented on May 20, 2026

    @SunsetTechuila
    Contributor

    primary-button-selector

    I expect this to be a bigger problem. We have:

    • Legacy button classes (btn)
    • Less legacy button classes (Button)
    • Legacy React button classes (prc-Button)
    • Current React button classes (prc-Button-gibberish)

    And sometimes there might be just one button, which can be non-primary

  7. SunsetTechuila commented on May 20, 2026

    @SunsetTechuila
    Contributor

    Another one:

    Image

    This one doesn't have a primary button at all. I guess we have to check if there is a primary button first and, if not, select the one whose variant isn't the default?*

    * It is possible that all buttons are default variants. Then we have to select one whose variant isn't invisible

  8. fregante commented on May 20, 2026

    @fregante
    MemberAuthor

    We have

    Yeah, that's the problem, there's no standard anywhere.

    The primary action would be:

    • the one button, if one button
    • the colored button, either red or green

    So far we don't have any forms that have both red and green buttons.

    I think something like button.danger, button.primary would work, but we don't have those easy classes.

  9. fregante commented on Jun 16, 2026

    @fregante
    MemberAuthor

    We have GitHubbers reading our issue probably 🙂 the modal in title is now auto-focused and pressing Enter will confirm it

    Image
  10. volantine commented on Oct 29, 2026

    @volantine

    Hi! I'm interested in working on this issue as my first contribution to Refined GitHub.

    I noticed that GitHub has since added autofocus to some dialogs. Is this feature still needed for the remaining dialogs, or has GitHub addressed most of the cases?

    I'd be happy to take this on if it's still relevant. Thanks!

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

    acceptedenhancementsmall

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions