Skip to content

docs(react-drawer): use non-modal OverlayDrawer when mounted inside a container - #43

Draft
mainframev wants to merge 1 commit into
masterfrom
fix/overlay-drawer-mountnode-focus
Draft

mainframev wants to merge 1 commit into
masterfrom
fix/overlay-drawer-mountnode-focus

Conversation

@mainframev

Copy link
Copy Markdown
Owner

Previous Behavior

The "Overlay inside container" story renders an OverlayDrawer into a mountNode with the default modalType="modal". The Drawer only covers its container, so the rest of the page stays visible and clickable, but Tabster still treats the Drawer as a trapped modal:

  • Clicking a control outside the container moves focus there, and Tabster pulls it back into the Drawer about 100ms later.
  • A click on an outside button still fires. If that button opens a modal Dialog, closing the Dialog restores focus to the button, which is outside every modalizer. Tabster's active modalizer becomes undefined, the Drawer stays aria-hidden="true", and every later click into the Drawer is pulled back out. The Drawer stays open but can't be reached.

inertTrapFocus behaves the same way. Reproduced on master with Cypress and the issue's repro.

New Behavior

  • The story uses modalType="non-modal" and explains when to choose it: a Drawer inside a container that leaves the rest of the page interactive is not modal.
  • New Cypress tests for an OverlayDrawer in a mountNode with modalType="non-modal":
    • focus stays on a control outside the container
    • after a modal Dialog opened from outside the container closes, focus can return to the Drawer, and the Drawer isn't aria-hidden

Both tests fail with modalType="modal" and pass with "non-modal". Non-modal gives every behavior the issue lists as expected.

No change file: only stories and a .cy.tsx file change.

Not in this PR: Tabster

The unreachable modal Drawer comes from Tabster's ModalizerAPI._onFocus (tabster 8.8.1, the latest release). When no modalizer is active, a user focus into a trapped modalizer doesn't activate it unless the focus was programmatic, so focus is pulled back out. Activating the focused modalizer when activeId is undefined fixes the scenario; I checked this with a runtime patch in Cypress. That change belongs in microsoft/tabster.

Related Issue(s)

… container

A Drawer rendered into a mountNode only covers that container, so the
rest of the page stays interactive. With the default modal type, Tabster
traps focus and pulls clicks outside back into the Drawer; when a modal
Dialog opened from outside closes, the Drawer is left aria-hidden and
unreachable. Use modalType="non-modal" in the story, explain why, and
cover the focus behaviour with Cypress tests.

Refs microsoft#35389

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant