Skip to content

[Bug]: Tab trap not working when Dialog is placed inside of Menu #34103

Open
@Dejvovo

Description

@Dejvovo

Component

Dialog

Package version

9.0.0

React version

18

Environment

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  npmPackages:
    @fluentui/react-components: ^9.0.0 => 9.61.4 
    @types/react: ^17 => 17.0.85 
    @types/react-dom: ^17 => 17.0.26 
    react: ^18 => 18.3.1 
    react-dom: ^18 => 18.3.1

Current Behavior

Tabbing is not trapped inside of the dialog, which is opened from within Menu component.

Expected Behavior

Tabbing should be trapped inside of the modal dialog. Dialog has explicitly set modalType="modal", which has the description: "The tab sequence is kept within the dialog". This is not happenning

Reproduction

https://stackblitz.com/edit/csmohdj7-nf3deanr?file=src%2Fexample.tsx

Steps to reproduce

  1. Open: https://stackblitz.com/edit/csmohdj7-nf3deanr?file=src%2Fexample.tsx
  2. Click Trigger menu
  3. Click Dialog trigger
  4. Try to Tab.
  5. Focus goes outside of dialog..

Are you reporting an Accessibility issue?

yes

Suggested severity

High - No workaround

Products/sites affected

No response

Are you willing to submit a PR to fix?

yes

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
    The provided reproduction is a minimal reproducible example of the bug.

Activity

Dejvovo

Dejvovo commented on Mar 27, 2025

@Dejvovo
Author

Workaround: Put dialog outside of the menu popover. https://stackblitz.com/edit/csmohdj7-qajzfjd3?file=src%2Fexample.tsx

sopranopillow

sopranopillow commented on Apr 5, 2025

@sopranopillow
Contributor

I see it reproing, seems like a tabster related issue(?)

Dejvovo

Dejvovo commented on Apr 7, 2025

@Dejvovo
Author

Ye, definitely seems like a tabster issue.
Problem is, i can't override this behaviour with my own javascript, because tabster eats the tab in the root and calls e.preventDefault()

khmakoto

khmakoto commented on Apr 25, 2025

@khmakoto
Member

A workaround for now while we investigate is to stop propagation at the DialogSurface level

https://stackblitz.com/edit/csmohdj7-ln3mk5tv?file=src%2Fexample.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @sopranopillow@khmakoto@ling1726@Dejvovo

    Issue actions

      [Bug]: Tab trap not working when Dialog is placed inside of Menu · Issue #34103 · microsoft/fluentui