Skip to content
TheChatArchiveThe Chat Archive
gpt-5.6-sol· 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 first inspect the repository structure and locate the shared focus-restoration logic and relevant tests for Alert Dialog, Dialog, and Popover. Then I’ll reproduce the behavior in the closest existing test harness, implement a general fix, and run targeted tests.

  3. Assistant

    rg is unavailable, so I’ll use grep and find to identify the implementations and examples.

  4. Assistant

    The repository already has detached-trigger browser tests, including a Dialog “Open programmatically” case. I’ll inspect those tests and the root/trigger state management to determine why programmatic opens retain a stale trigger reference.

  5. Assistant

    The existing test only verifies payload selection, not focus restoration. The likely distinction is between the “associated trigger” (needed for payload/ARIA/positioning) and the element that actually held focus when a controlled open occurred. I’ll inspect the store and FloatingFocusManager’s capture/return behavior before choosing the narrowest shared fix.

  6. Assistant

    FloatingFocusManager defaults to the current floating DOM reference, which is deliberately set to the selected trigger. It does have a “previously focused element” fallback, but only uses it when the reference is disconnected. I’ll inspect how that previous element is recorded and how Popup computes finalFocus; a component-level explicit return target may already be the intended extension point.

  7. Assistant

    Popover already passes the associated trigger as a focus-guard neighbor, but not as an explicit return target. The manager captures the active element at mount in a global weak-ref stack. I’ll inspect the mount timing and Dialog equivalent, then determine whether changing default return order to “previously focused element first” is safe or whether we need a per-open origin to avoid nested/stale global state.

  8. Assistant

    A robust shared rule is available inside FloatingFocusManager: when opening without a trigger interaction (openInteractionType is empty), return to the element focused at that specific manager mount rather than the associated positioning/ARIA trigger. For genuine trigger keyboard/pointer opens, preserve existing return-to-trigger behavior. I’ll inspect focus traversal utilities so removal of the origin can fall back to the next focusable element near its former DOM position, as requested, rather than silently returning to the unrelated associated trigger.

  9. Assistant

    The manager can capture both the focused origin and its next tabbable neighbor before focus enters the popup. I’ll implement this only for default (boolean) return-focus behavior and only for programmatic opens. Explicit finalFocus remains authoritative, trigger-originated opens still return to their trigger, and initial opens from <body> retain the trigger fallback. If the captured origin is removed, the captured next tabbable element is used if still connected.

  10. Assistant

    Python is unavailable, so I’ll apply the same targeted edit with a Node script and inspect the diff.

  11. Assistant

    Before creating any temporary reproduction, I’ll run the existing focused manager and component suites. These include programmatic open/close cases and should reveal compatibility issues in default focus semantics.

  12. Assistant

    The test command was blocked by Corepack’s download confirmation rather than code. I’ll disable the prompt and run a smaller first batch with a longer allowance unavailable tool timeout fixed likely 10 sec. Tool timeout schema no timeout. commands max 10 sec. Could run background poll.

  13. Assistant

    The targeted browser run is now executing non-interactively in the background. I’ll poll its status and inspect failures when complete.

  14. Assistant

    Some detached-trigger tests were skipped because the command did not set VITEST_ENV=chromium; the manager suite is still running. I’ll let it complete, then rerun true Chromium suites with the repository’s environment variable.

  15. Assistant

    The broad inference from an empty interaction type breaks an existing keep-mounted manager case, confirming it should be opt-in at the popup component layer. I’ll add an internal manager flag and enable it in Dialog and Popover only when their store reports no trigger open method. Alert Dialog shares DialogPopup, so all three affected components are covered while generic focus-manager semantics remain unchanged.

  16. Assistant

    The automated dependency insertion matched an earlier effect instead of the return-focus effect. I’ll correct that dependency placement before testing; otherwise the earlier effect reruns unnecessarily and the intended effect risks stale configuration.

  17. Assistant

    The dependency is now correct. I’ll first confirm the previously failing manager suite passes, then execute the detached-trigger suites under actual Chromium (where those tests are enabled).

  18. Assistant

    I’ll poll the focused regression suite.

  19. Assistant

    The manager suite now passes all 49 enabled tests. I’ll run Dialog, Popover, and Alert Dialog detached/multiple-trigger suites in Chromium.

  20. Assistant

    I’ll poll the Chromium component suites.

  21. Assistant

    Chromium tests could not launch because the Playwright browser binary is missing. Per the environment guidance, I’ll install the required Chromium binary and rerun; this changes only the external cache, not repository files.

  22. Assistant

    I’ll poll the browser installation.

  23. Assistant

    The download is progressing normally; I’ll wait for completion.

  24. Assistant

    The headless shell is the final required artifact; I’ll poll once more.

  25. Assistant

    Chromium installed successfully. I’ll rerun the three affected component suites.

  26. Assistant

    I’ll poll the actual Chromium run.

  27. Assistant

    All 81 enabled affected-component Chromium tests pass. I’ll inspect the documented DOM ordering to validate the removed-origin fallback against the actual example, then run lint/type checks.

  28. Assistant

    The documented programmatic button follows the three triggers, so capturing its next tabbable neighbor at open provides the requested DOM-position fallback if it is removed (wrapping according to the library’s existing tabbable traversal). The root lint script expanded to all workspaces and exceeded the command window, so I’ll run direct lint on changed files and a background TypeScript build.

  29. Assistant

    Direct lint passed with no findings. I’ll poll the package TypeScript check.

  30. Assistant

    The TypeScript build is still running; I’ll wait for completion.

  31. Assistant

    No diagnostics have appeared, but compilation has not exited yet. I’ll poll once more and then inspect the final diff/status.

  32. Assistant

    One edge-case review found an important detail: because portaled popup controls are mounted before the focus-manager layout effect, the generic “next tabbable” may be a close button that disappears with the popup. I’ll refine the captured fallback to select the next tabbable element outside the popup subtree, preserving the originating control’s page context when the origin is removed.

  33. Assistant

    The fallback now excludes popup descendants and safely handles empty/no-origin lists. I’ll rerun the manager regression suite and all affected Chromium suites after this edge-case refinement.

  34. Assistant

    I’ll poll the combined final test run.

  35. Assistant

    Final tests pass: 49 manager tests and 81 affected-component Chromium tests. I’ll run final lint/type checking and inspect repository status to ensure only intended source files changed and no build artifacts remain.

  36. Assistant

    The final checks pass and only the three intended source files are modified. I’ll review the complete diff once for API scope, comments, and focus fallback behavior before submitting.

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