Skip to content

Dialog backdrop passes through click events #3203

Description

@Hwacc

3# 🐛 Bug report

Dialog backdrop can allow click-through when an underlying element explicitly sets pointer-events: auto.

When a Zag Dialog is opened, background content should not be interactive. However, the current pointer-blocking strategy appears to set pointer-events: none on body. If a descendant under the backdrop has pointer-events: auto, that element can still receive clicks even though it is visually covered by the backdrop.

Kind like #1720

💥 Steps to reproduce

  1. Open Dialog
  2. Try to hover or click the link element

💻 Link to reproduction

See: https://stackblitz.com/edit/3gfyhysi?file=src%2FDialog.tsx

🧐 Expected behavior

When a modal dialog is open, background content should not receive pointer events, regardless of whether descendants explicitly set pointer-events: auto.

The backdrop/positioner should reliably block interaction with all non-dialog content.

🧭 Possible Solution

  1. Use an inert-based strategy for modal background suppression, such as suppressOthers() which already in zagjs (suppressOthers is a inert-frist prevented function), instead of relying only on aria-hidden and body-level pointer-events: none.

  2. A quick hack way is let your dialog backdrop element has pointer-events: auto to intercept and consume the click event.

🌍 System information

Software Version(s)
Zag Version @zag-js/dialog@1.41.2
Browser Chrome
Operating System Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions