Skip to content

[Bug]: Pressing esc should only close a single/focused modal #20426

@tay1orjones

Description

@tay1orjones

Package

@carbon/react

Browser

Chrome

Package version

1.90

React version

19

Description

While there is not formal support for nested modals, our partner libraries make use of them. A recent change, probably #19908, made it so that a press of esc closes all open modals instead of just the topmost/focused one.

IIRC the spec for <dialog> actually supports this idea now too. This should be fixed and a test written to cover it. It might be best for that test to have a comment or be wrapped in a describe block or something saying "nesting of modals is not formally supported but tested here to ensure downstream compatibility with partner libraries"

Reproduction/example

https://deploy-preview-8171--carbon-for-ibm-products.netlify.app/?path=/story/components-tearsheet--stacked

Steps to reproduce

open multiples and press esc, all are closed at once

Suggested Severity

Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.

Application/PAL

No response

Code of Conduct

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

Status
✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions