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

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

  1. User

    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.

    Interface

    No new interfaces are introduced.

  2. Assistant

    I’ll trace the shared open/close focus-management path across Dialog, Alert Dialog, and Popover, starting with the repository contribution guidance, then add regression coverage and run the focused checks.

  3. Assistant

    rg isn’t installed in this checkout, so I’m using targeted find/grep searches. The likely fix belongs in shared root-level focus restoration rather than in the three documentation demos independently.

  4. Assistant

    The cause is now clear: focus restoration always prefers the configured “active trigger.” In these controlled examples, the programmatic button opens content associated with trigger 2, so association and focus origin are different. I’m changing the shared focus manager to remember the element focused at open time (plus its nearest DOM-order fallback), while preserving explicit finalFocus behavior.

  5. Assistant

    The shared logic and two dialog regressions are in place: one for restoring to the programmatic opener and one for restoring to the next control when that opener disappears during close. I’m running the focused suite now; after that I’ll cover Popover’s distinct store path.

  6. Assistant

    Both focused component suites pass, including Popover’s separate controlled-trigger path, and the underlying focus-manager suite is green. I’m doing formatting/type/lint verification now and checking the final diff for unintended behavior changes.

  7. Assistant

    All local static checks passed. Chromium verification could not start because this environment lacks the Playwright Chromium executable; I’m not downloading it because the task explicitly excludes internet/external sources. The jsdom regressions and shared focus-manager suite remain fully green.

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