Skip to content

DialogHost (MaterialDesignEmbeddedDialogHost): Tab key can focus/activate controls behind the dialog #4027

@BrensNina

Description

@BrensNina

Bug explanation

When using DialogHost with Style="{StaticResource MaterialDesignEmbeddedDialogHost}", while the dialog is open the user can press Tab and keyboard focus can move to focusable controls behind the dialog (the main view content). This allows interacting with the background UI while the dialog is open.

This looks like a missing focus trap / modality issue for the embedded dialog style.

Expected behavior

While the dialog is open, keyboard focus should be trapped inside the dialog.
Tab should not navigate to controls behind the dialog, and background controls should not be activatable via keyboard.

Actual behavior

With MaterialDesignEmbeddedDialogHost, focus can “escape” to background controls and they can be activated even though the dialog is open.

Steps to reproduce

Create a view with focusable controls behind the dialog (e.g., TextBox, Button).
Use a DialogHost with Style="{StaticResource MaterialDesignEmbeddedDialogHost}".
Open the dialog.
Press Tab repeatedly.
Observe focus reaching background controls (and they can be activated via Enter/Space).

Minimal XAML snippet

<materialDesign:DialogHost Style="{StaticResource MaterialDesignEmbeddedDialogHost}">
    <!-- Main content behind -->
    <Grid>
        <StackPanel>
            <TextBox />
            <Button Content="Background button" />
            <Button Content="Open dialog" />
        </StackPanel>
    </Grid>

    <materialDesign:DialogHost.DialogContent>
        <StackPanel>
            <TextBox />
            <Button Content="Close"
                    Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" />
        </StackPanel>
    </materialDesign:DialogHost.DialogContent>
</materialDesign:DialogHost>

Version

5.3.1 lastest stable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugevaluation requiredItems is pending review or evaluation by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions