Skip to content
TheChatArchiveThe Chat Archive
gpt-5.6-luna· openaiHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Accessibility: Focus moves to the wrong trigger when using "Open…

  1. User

    ISSUE DESCRIPTION

    Accessibility: Focus moves to the wrong trigger when using "Open programmatically" buttons

    Current behavior

    In the Alert Dialog, Dialog and Popover components, there is a variant that includes the option to use multiple triggers to open the dialogs. When using the "Open Programmatically" button to open the dialog/popup, then closing it, focus moves to a different control than the one that triggered the dialog/popup.

    See:

    This could cause failures against WCAG 2.2 Success Criterion 2.4.3 Focus Order when implemented.

    Expected behavior

    Keyboard focus should move back to the originating control (if available) when closing a dialog as long as a page refresh or redirection is not triggered.

    If the control is no longer available, focus should move next to that originating control's position in the DOM.

    Reproducible example

    1. Go to [Alert Dialog: Controlled mode with multiple triggers](https://base-ui.com/react/components/alert-dialog#controlled-mode-with-multiple-triggers
    2. Using keyboard, move focus to the "open programmatically" button
    3. Press Enter to activate the control and open the dialog
    4. Press Esc or activate the close button to close the dialog
    5. Note focus has moved back to the "Delete" button and not the "open programmatically" button as expected.

    Base UI version

    v1.2.0

    Which browser are you using?

    Chrome 145.0.7632.76

    Which OS are you using?

    Mac OS Tahoe 26.2

    Which assistive tech are you using (if applicable)?

    Keyboard

    Additional context

    Recommend keeping track of focus and returning it to the originating control.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /base-ui, current file: none) bash-$

  2. Assistant

    I’ll trace the shared dialog/popover focus-restoration implementation, identify how the close target is currently selected, then update the common logic so each open trigger is remembered (including programmatic opens), with a safe DOM-position fallback when the original trigger disappears. I’ll run focused tests and the relevant suite, then review the diff.

  3. Assistant

    The shared focus manager was the right fix point: dialog and popover both use it, while the existing default restoration prefers the registered reference trigger. I added a transient record of the element focused when an open event has no trigger (the programmatic case), and restoration now prefers that element when it remains connected, otherwise retaining existing behavior. I also excluded document.body so non-user-initiated opens do not treat the body as a trigger. The focused tests were attempted, but the repository’s pnpm/Vitest and eslint invocations exceeded the terminal timeout; the diff passes whitespace validation and the changed field is present in the internal event type.Checklist review:

    • Reproduced the reported error: not independently run in a browser; the code path was traced and the stale-reference behavior was confirmed from the focus manager implementation.
    • Confirmed the fix resolves it: verified by code-path analysis; automated focused tests could not complete because commands timed out.
    • Considered edge cases: connected/disconnected originating controls, missing trigger metadata, body focus, ordinary trigger opens, and explicit finalFocus behavior.
    • Ran affected existing tests: attempted the dialog/popover popup tests and lint validation; the package commands timed out in this environment, while git diff --check passed.

    I’m submitting the focused shared implementation change now.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.