Skip to content
TheChatArchiveThe Chat Archive
QwenQwen/Qwen3.6-27B· alibabaHugging 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. Qwen Assistant

    Let me start by understanding the issue. The problem is about accessibility - when using "Open programmatically" buttons to open dialogs (Alert Dialog, Dialog, Popover), after closing the dialog, focus moves to the wrong trigger button instead of the one that originally opened the dialog.

    Let me first explore the repository structure to understand the codebase.

  3. Qwen Assistant

    Let me explore the packages directory to find the Alert Dialog, Dialog, and Popover components.

  4. Qwen Assistant

    Let me continue exploring the packages/react directory.

  5. Qwen Assistant

    Let me look at the structure of these components and find where focus management is handled.

  6. Qwen Assistant

    I see that AlertDialogRoot uses useRenderDialogRoot from the Dialog component. Let me look at the Dialog component's root implementation.

  7. Qwen Assistant

    Now let me look at the useDialogRoot hook which handles the dialog interactions:

  8. Qwen Assistant

    Now I see there's a usePopupInteractionProps function from the ../../utils/popups module. Let me look at that since it handles the interaction props including focus management:

  9. Qwen Assistant

    Now let me look at the store to understand how trigger elements are tracked:

  10. Qwen Assistant

    Now let me look at the dialog store to understand how it manages triggers and the open/close behavior:

  11. Qwen Assistant

    Now let me look at where focus is managed when closing the dialog. Let me look at the floating-ui-react focus management:

  12. Qwen Assistant

    Let me look at the FloatingFocusManager, which is likely responsible for focus management:

  13. Qwen Assistant

    This is a key file. I can see that the focus return logic is in the getReturnElement function. It checks domReference which comes from the context. Let me see how domReference is set:

  14. Qwen Assistant

    I see domReference comes from store.useState('domReferenceElement'). Let me look at the FloatingRootStore to understand how the domReferenceElement is set:

  15. Qwen Assistant

    I see that domReferenceElement is initialized from referenceElement. Now I need to understand how the reference element is set when opening programmatically. Let me look at where triggers set this:

  16. Qwen Assistant

    This is very helpful. I see that the domReferenceElement is used to track which element triggered the floating/popup for focus return purposes. Now let me look at how triggers set the domReferenceElement. Let me check the useSyncedFloatingRootContext and the trigger implementation:

  17. Qwen Assistant

    Now I understand the flow better. The referenceElement (which becomes domReferenceElement) is set from popupStore.useState('activeTriggerElement'). So the key is that when a popup is opened programmatically, we need to track which element actually triggered the open, so focus can be returned correctly.

    Let me look at the Dialog trigger implementation to see how triggers work:

  18. Qwen Assistant

    Now let me look at the test file to understand the issue better and the example of controlled mode with multiple triggers:

  19. Qwen Assistant

    Now I understand the issue better. Let me look at the docs examples that were mentioned in the issue:

  20. Qwen Assistant

    Now I can see the issue clearly. When clicking the "Open programmatically" button, the code sets triggerId to 'trigger-2' and opens the dialog. However, the actual element that triggered the dialog (the "Open programmatically" button) is not registered as a trigger. When the dialog closes, focus should return to the "Open programmatically" button, but instead it goes to the trigger with id="trigger-2" (which is "Open 2").

    Let me trace through the code to understand the issue:

    1. When the user clicks "Open programmatically", setTriggerId('trigger-2') is called
    2. This sets activeTriggerId to 'trigger-2' and activeTriggerElement to the element with that ID
    3. When the dialog closes, getReturnElement() in FloatingFocusManager checks domReference?.isConnected which points to the element with id "trigger-2"
    4. Focus returns to the "Open 2" button instead of the "Open programmatically" button

    The issue is that when opening programmatically via triggerId, the system doesn't know that the actual element that initiated the action (the "Open programmatically" button) should receive focus back.

    Let me look at how setOpenTriggerState works and how the focus return mechanism uses the trigger element:

  21. Qwen Assistant

    Let me look at the setOpenTriggerState function again more closely:

  22. Qwen Assistant

    Now I understand the issue better. When opening programmatically with a triggerId, the activeTriggerElement gets set to the element matching that ID. But the element that actually initiated the action (the "Open programmatically" button outside the component) is lost.

    The key insight is that the problem happens when:

    1. A dialog is opened via triggerId prop or programmatically (via handle)
    2. The triggering element is a "programmatic button" that's not a Dialog.Trigger itself
    3. When the dialog closes, focus returns to the element identified by triggerId (the Dialog.Trigger), not the actual element that was interacted with

    The solution should be to track the actual element that initiated the open action and return focus to it. Let me look at how the useSyncedFloatingRootContext syncs the domReferenceElement:

  23. Qwen Assistant

    Now I see the issue. The referenceElement is synced from popupStore.useState('activeTriggerElement'). But the problem is that when the dialog is opened programmatically by setting triggerId, the activeTriggerElement is updated to the element with that ID (through useTriggerDataForwarding). However, the actual element that initiated the open (the "Open programmatically" button) is not tracked.

    Let me trace through more carefully what happens when triggerId changes:

  24. Qwen Assistant

    Now let me look at how useTriggerDataForwarding updates the activeTriggerElement when triggerId changes:

  25. Qwen Assistant

    Now I understand the full picture. The issue is that when a dialog is opened programmatically (via an external button), the activeTriggerElement points to the Dialog.Trigger element (which has the matching triggerId), not the actual element that was clicked (the "Open programmatically" button).

    The solution should preserve the element that was active before the dialog was opened (if the open was not triggered by a registered trigger). Let me look at how the focus return mechanism works:

  26. Qwen Assistant

    I see the issue. In getReturnElement(), the return logic checks if domReference?.isConnected and returns it. But domReference is set from activeTriggerElement, which is the Dialog.Trigger element, not the actual element that was clicked to open programmatically.

    The solution needs to track the actual element that was focused/active when the popup was opened programmatically. Let me check if there's already a mechanism for this:

  27. Qwen Assistant

    There's already a previouslyFocusedElement tracking mechanism. Looking at getReturnElement():

    if (typeof resolvedReturnFocusValue === 'boolean') {
      if (domReference?.isConnected) {
        return domReference;
      }
      return getPreviouslyFocusedElement() || null;
    }
    

    The fallback to getPreviouslyFocusedElement() is only used when domReference is not connected. But in our case, domReference is connected (it's the Dialog.Trigger element), so the previously focused element is never used.

    The core problem is that when opening programmatically, the domReference is set to the Dialog.Trigger element (via triggerId), but we want focus to return to the actual element that initiated the action.

    Let me think about the solution. The issue is specifically about how domReferenceElement is synced when opening programmatically:

    1. User clicks "Open programmatically" button
    2. User's code sets triggerId to 'trigger-2'
    3. The Dialog.Trigger with id="trigger-2" updates its activeTriggerElement to itself
    4. domReferenceElement becomes the Dialog.Trigger element
    5. When dialog closes, focus returns to Dialog.Trigger instead of "Open programmatically" button

    The fix should be: When the popup is opened but the actual interaction did NOT come from a registered trigger element (i.e., it came from an external button), we should NOT update domReferenceElement to point to the registered trigger. Instead, we should keep the previously focused element as the return target.

    Let me look at how we can detect this scenario. The key is in the useSyncedFloatingRootContext:

  28. Qwen Assistant

    Now let me think about this more carefully. The real issue is about tracking the actual element that initiated the open action. When opening programmatically via a non-trigger button, we need to:

    1. Track the element that was focused when the popup was opened (if not opened by a registered trigger)
    2. Return focus to that element when closing

    Looking at the code flow more carefully:

    1. In useSyncedFloatingRootContext.ts, referenceElement is synced from popupStore.useState('activeTriggerElement')
    2. The domReferenceElement is set to referenceElement when it's an element
    3. When the dialog closes, FloatingFocusManager uses domReference to determine where to return focus

    The problem is that when triggerId is set externally (programmatically), the activeTriggerElement gets updated to the matching Dialog.Trigger element through useTriggerDataForwarding.

    Let me look at how we can distinguish between:

    • Opening via a registered trigger (clicking Dialog.Trigger) - should return focus to that trigger
    • Opening programmatically via triggerId prop - should return focus to the element that was focused when the open happened

    The key insight is that when opening programmatically, the eventDetails.trigger won't be set because no trigger was actually clicked. Let me check how DialogStore.setOpen handles this:

  29. Qwen Assistant

    I see. When opening programmatically via triggerId prop, the eventDetails.trigger is undefined. The setOpenTriggerState function only sets activeTriggerElement if trigger is provided or if open is false (to preserve the previous value for focus return).

    But wait, let me check what happens when triggerId prop changes. The triggerIdProp is synced to the store, and there's logic that resolves activeTriggerId from it:

  30. Qwen Assistant

    I see! The activeTriggerIdSelector returns state.triggerIdProp ?? state.activeTriggerId. So when triggerId is set as a prop, it takes precedence. This means when triggerIdProp is set to 'trigger-2', the selector will return 'trigger-2'.

    Now let me look at useTriggerDataForwarding - when isMountedByThisTrigger becomes true (because triggerIdProp matches), it updates activeTriggerElement:

  31. Qwen Assistant

    So when the triggerId prop changes to match a trigger, that trigger's useTriggerDataForwarding updates activeTriggerElement to its own element. This is what causes the focus to return to the wrong element.

    Now I need to think about the solution. The issue is that when opening programmatically:

    1. The activeTriggerElement is set to the Dialog.Trigger matching the triggerId
    2. But the actual element that initiated the open (the programmatic button) is not tracked

    The solution should be to track the element that was focused when the popup was opened, regardless of whether a trigger was involved. This can be done by storing a "focus return element" that is set when the popup opens, and used when it closes.

    Let me look at what information is available at the time the popup opens programmatically. When the user clicks the "Open programmatically" button:

    1. That button is the active/focused element
    2. The code sets triggerId to 'trigger-2' and open to true
    3. The Dialog.Trigger with id="trigger-2" becomes the active trigger

    The solution: We should track the activeElement at the time of opening (when the open state changes from false to true), and use that as the focus return target instead of the domReferenceElement when the popup wasn't opened by a registered trigger.

    Looking at the code in FloatingFocusManager.tsx:

  32. Qwen Assistant

    I see that addPreviouslyFocusedElement(previouslyFocusedElement) is called when the popup mounts. This captures the active element at mount time. However, the issue is that by the time the popup mounts and this effect runs, the Dialog.Trigger with id="trigger-2" might have already updated itself as the active trigger, and the actual button that was clicked might have already lost focus.

    Wait, let me re-read the flow:

    1. User clicks "Open programmatically" button
    2. onClick sets triggerId='trigger-2' and open=true
    3. React re-renders with the new props
    4. Dialog opens
    5. Dialog.Trigger with id="trigger-2" updates activeTriggerElement to itself
    6. useSyncedFloatingRootContext syncs referenceElement to the Dialog.Trigger element
    7. FloatingFocusManager mounts and captures previouslyFocusedElement

    Actually, at step 7, the previouslyFocusedElement would still be the "Open programmatically" button because the focus hasn't moved yet - the popup is just mounting.

    But wait, the issue is in getReturnElement():

    if (typeof resolvedReturnFocusValue === 'boolean') {
      if (domReference?.isConnected) {
        return domReference;  // <-- This returns the Dialog.Trigger, not the previously focused element
      }
      return getPreviouslyFocusedElement() || null;
    }
    

    The problem is that domReference (which is activeTriggerElement, pointing to the Dialog.Trigger) is connected, so it's used instead of the previously focused element.

    The fix should be: when the popup was NOT opened by a registered trigger (i.e., opened programmatically), we should not use domReference as the return target.

    Let me look at how we can detect if the popup was opened by a trigger click vs. programmatically:

  33. Qwen Assistant

    I think the best approach is to modify the useSyncedFloatingRootContext to not update domReferenceElement when the open was triggered programmatically (i.e., the activeTriggerElement wasn't set by an actual trigger interaction).

    However, a simpler approach might be to track whether the popup was opened by a registered trigger click. If not, we should use the previously focused element instead of domReference.

    Let me look at another approach - instead of modifying the floating-ui code, we can modify how the store tracks the focus return element. The popup store already has activeTriggerElement, but we could add a separate state for the element that should receive focus.

    Actually, looking at the code more carefully, I think the simplest fix is in useSyncedFloatingRootContext. When the referenceElement changes but the popup is opening (not due to a trigger interaction), we should not update domReferenceElement.

    But wait - there's a subtlety here. The referenceElement is synced from activeTriggerElement, which is updated by useTriggerDataForwarding. When triggerId changes and matches a trigger, that trigger updates activeTriggerElement.

    The real fix should be: When the triggerId prop changes to a new value that wasn't the result of a user interaction on a trigger, we should track the actual active element at that time as the focus return target.

    Let me look at this from a different angle. The useTriggerDataForwarding hook updates activeTriggerElement when isMountedByThisTrigger is true. This happens when triggerIdProp matches the trigger's ID. The issue is that this update happens even when the open was not triggered by clicking that trigger.

    One clean solution: Add a new state to track whether the open was initiated by a registered trigger interaction. If not, we should preserve the domReferenceElement from the time of opening (or use the previously focused element).

    Let me examine the useSyncedFloatingRootContext more carefully:

  34. Qwen Assistant

    Now I understand the architecture better. The issue is in how domReferenceElement is synced. When referenceElement (from activeTriggerElement) changes due to a triggerId prop change (rather than a trigger click), domReferenceElement gets updated to point to the new trigger, even though that trigger wasn't the one that initiated the open.

    Let me think about the cleanest fix:

    Option 1: Don't update domReferenceElement when the popup is opening programmatically (via triggerId prop change).

    Option 2: Track separately whether the open was initiated by a trigger interaction or programmatically, and use that to decide which element to return focus to.

    Option 3: When FloatingFocusManager returns focus, check if the domReference element is actually the element that was focused when the popup opened (i.e., check if focus has ever been on domReference since mount).

    I think Option 1 is the cleanest approach. The key insight is that domReferenceElement should only be updated when the user interacts with a trigger, not when the triggerId prop changes programmatically.

    Looking at the code flow:

    1. When a user clicks a Dialog.Trigger, useClick calls store.setOpen(true, eventDetails) with eventDetails.trigger set to the clicked trigger element
    2. When triggerId prop changes programmatically, no trigger element is provided in eventDetails

    So we need to differentiate between these two cases and only update domReferenceElement in case 1.

    Let me look at how the store can track this:

  35. Qwen Assistant

    I see that FloatingRootStore.dispatchOpenChange emits a triggerElement in the FloatingUIOpenChangeDetails. This could be used to track which element actually triggered the open.

    Let me look at the FloatingUIOpenChangeDetails type:

  36. Qwen Assistant

    Now I have a clear picture. The FloatingUIOpenChangeDetails includes triggerElement which indicates the element that triggered the open. In FloatingFocusManager, this is available in the onOpenChangeLocal callback.

    Let me look at how FloatingFocusManager handles this:

  37. Qwen Assistant

    Now I understand the issue and where to fix it. The key is in getReturnElement():

    if (typeof resolvedReturnFocusValue === 'boolean') {
      if (domReference?.isConnected) {
        return domReference;  // <-- Problem: always returns domReference if connected
      }
      return getPreviouslyFocusedElement() || null;
    }
    

    The fix should track whether the popup was opened by a trigger element interaction. If triggerElement was provided when opening, use domReference. If not (programmatic open), use previouslyFocusedElement.

    Let me implement this fix. I'll need to:

    1. Track whether the popup was opened with a triggerElement
    2. Use that information in getReturnElement() to decide whether to return focus to domReference or previouslyFocusedElement
  38. Qwen Assistant

    Now I'll create a comprehensive fix. The approach is to track whether the popup was opened by a registered trigger interaction. When the open change event fires with a triggerElement, we know a trigger was clicked. When it fires without a triggerElement, it was opened programmatically.

    Let me create the fix:

  39. Qwen Assistant

    I see there are several refs already being used. I'll add a new ref to track the trigger element that opened the popup, and modify the onOpenChangeLocal handler and getReturnElement function accordingly.

  40. Qwen Assistant

    Now I understand the structure. I need to:

    1. Add a ref to track whether the popup was opened by a registered trigger element
    2. Update the onOpenChangeLocal handler to capture this information
    3. Modify getReturnElement() to use the previously focused element when the popup was opened programmatically

    Let me make the changes:

  41. Qwen Assistant

    Now I understand the complete picture. I need to modify the FloatingFocusManager.tsx file. The fix needs to:

    1. Track when the popup is opened (via openchange event) and whether a triggerElement was provided
    2. If no triggerElement was provided (meaning it was opened programmatically), don't use domReference as the return focus target - use previouslyFocusedElement instead

    Let me look at the specific lines I need to modify:

  42. Qwen Assistant

    Now I'll make my fix. I need to:

    1. Add a ref to track the trigger element that opened the popup
    2. Update onOpenChangeLocal to capture the triggerElement when the popup opens
    3. Modify getReturnElement to check if the popup was opened programmatically
  43. Qwen Assistant

    Good, now I need to modify the onOpenChangeLocal function to track when the popup is opened with a trigger element:

  44. Qwen Assistant

    Now I need to modify onOpenChangeLocal to capture the triggerElement when the popup opens:

  45. Qwen Assistant

    I need to use the correct format with >>> SEARCH and >>> REPLACE markers on separate lines.

  46. Qwen Assistant

    The search string wasn't found in the displayed lines. Let me navigate to line 742 first and then try the replacement. </tool_call>

  47. Qwen Assistant

    I need to use the goto command to navigate to the right line, then use replace.

  48. Qwen Assistant

    Now I can see the code. Let me apply the edit to modify the onOpenChangeLocal function:

  49. Qwen Assistant

    Now I need to modify the getReturnElement function to use triggerElementRef to determine whether to return focus to domReference or the previously focused element:

  50. Qwen Assistant

    I also need to update the fallback logic for when returnFocusValueOrFn is a ref or function:

  51. Qwen Assistant

    I need to reconsider my approach. The openchange event fires before the FloatingFocusManager mounts, so my listener won't capture the trigger element. Let me use a different approach: compare previouslyFocusedElement with domReference at mount time to determine if the popup was opened programmatically.

  52. Qwen Assistant

    Let me reconsider my approach. The openchange event fires before FloatingFocusManager mounts, so my listener won't capture the trigger element. A better approach is to compare previouslyFocusedElement with domReference at mount time to determine if the popup was opened programmatically.

    If the previously focused element is the same as domReference (or contained in it), it was likely opened by a trigger click. If they're different, it was opened programmatically.

    Let me revert my changes and implement a cleaner approach:

  53. Qwen Assistant

    I see I accidentally removed the lastFocusedTabbableRef line. Let me revert all my changes and implement a cleaner approach.

  54. Qwen Assistant

    Let me take a different approach. The key insight is that the openchange event with triggerElement is emitted BEFORE the FloatingFocusManager mounts, so my listener won't capture it.

    A better approach is to determine at mount time whether the popup was opened programmatically by comparing previouslyFocusedElement with domReference:

    • If they're the same (or previouslyFocusedElement contains/equals domReference), it was opened by a trigger click
    • If they're different, it was opened programmatically

    Let me implement this approach.

  55. Qwen Assistant

    Let me implement a cleaner approach. I'll add a ref to track whether the popup was opened by the trigger element itself, by comparing previouslyFocusedElement with domReference at mount time.

  56. Qwen Assistant

    Good, now I need to set openedByTriggerRef at mount time. Let me find the section where the cleanup effect is set up and modify it to determine if the popup was opened by a trigger:

  57. Qwen Assistant

    ...

  58. Qwen Assistant

    Now I need to update the getReturnElement function to use openedByTriggerRef to determine whether to return focus to domReference:

  59. Qwen Assistant

    I need to check the current state of my changes and verify they look correct. Let me review the diff.

  60. Qwen Assistant

    The changes look correct. Let me now run the existing tests to make sure I haven't broken anything, and also check if there are tests that specifically cover this focus return behavior.

  61. Qwen Assistant

    Let me search for focus-related tests in the FloatingFocusManager test file and dialog tests to understand how to verify my fix.

  62. Qwen Assistant

    The issue is about focus management when dialogs are opened programmatically. Let me run the existing tests to make sure my changes don't break anything, and then create a test to verify my fix works correctly.

    Let me first check if there are existing tests for focus return behavior.

  63. Qwen Assistant

    Let me first verify the code changes are correct, then run the tests to see if anything is broken. Let me also think about edge cases for my fix.

    The fix I implemented:

    1. Added openedByTriggerRef to track whether the popup was opened by a trigger element interaction
    2. At mount time, we compare previouslyFocusedElement with domReference to determine if the popup was opened by a trigger
    3. In getReturnElement(), we only return domReference if openedByTriggerRef.current is true

    Edge cases to consider:

    1. When a user clicks a trigger button - previouslyFocusedElement will be the trigger (or the button being clicked), which should match domReference
    2. When a user uses keyboard (Tab + Enter) on a trigger - previouslyFocusedElement will be the trigger, matching domReference
    3. When opened programmatically via an external button - previouslyFocusedElement will be the external button, not matching domReference
    4. When the popup is initially open (defaultOpen=true) - previouslyFocusedElement would be body likely

    Let me run the tests to see if the changes work.

  64. Qwen Assistant

    Let me try running the tests with a different approach - using npx or checking if the test command is available.

  65. Qwen Assistant

    Let me try a different approach to run tests - using vitest directly.

  66. Qwen Assistant

    I have a failing test. Let me look at it to understand what's happening.

  67. Qwen Assistant

    Let me look at the full test to understand the scenario better.

  68. Qwen Assistant

    I see the issue. My heuristic for detecting programmatic opens is too strict. The failing test has focus inside the floating element (on "child"), which means previouslyFocusedElement !== domReference, so my code thinks it was opened programmatically. But actually, the user did click the reference, and focus just moved inside the floating.

    I need to also check if previouslyFocusedElement is inside the floating element - if so, the popup is being used normally and should return to domReference.

  69. Qwen Assistant

    Wait, my logic is still wrong. In the failing test, when the user clicks the reference button, focus goes to the child button inside the floating element. So when the effect runs:

    • previouslyFocusedElement is the child button
    • floatingFocusElement is the floating element (which contains child)
    • So contains(floatingFocusElement, previouslyFocusedElement) would be true

    But this is exactly what my new check does! So the test should pass now. Let me run it again to confirm.

  70. Qwen Assistant

    All tests pass now. Let me run a few more related tests to make sure my changes don't break other components that use the FloatingFocusManager.

  71. Qwen Assistant

    Let me also run the Popover and Alert Dialog tests to ensure my fix doesn't break them.

  72. Qwen Assistant

    ...

  73. Qwen Assistant

    All tests pass! Now let me create a simple test script to verify that my fix actually solves the issue described in the bug report.

  74. Qwen Assistant

    The test file needs to be in the project directory with a proper naming convention. Let me create a temporary test file within the project structure.

  75. Qwen Assistant

    The tests are skipped because they require a real browser environment (not JSDOM). Let me remove the test file I created since I shouldn't be adding tests, and instead verify my fix through the existing test suite.

  76. Qwen Assistant

    Let me verify my final changes by reviewing the diff:

  77. Qwen Assistant

    Let me run a broader set of tests to make sure the fix doesn't break any other components that use FloatingFocusManager.

  78. Qwen Assistant

    All tests pass! Let me also run a few more related tests to ensure my fix is robust:

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