radix-ui / primitives

Radix Primitives is an open-source UI component library for building high-quality, accessible design systems and web apps. Maintained by @workos.
https://radix-ui.com/primitives
MIT License
15.93k stars 833 forks source link

[AlertDialog] forceMount causes document body scroll-locked even when AlertDialog is closed #3100

Open seedy opened 2 months ago

seedy commented 2 months ago

Bug report

Current Behavior

I want to animate AlertDialog entering and closing, therefore I was planning on using forceMount prop.

Document body is scroll-locked when applying forceMount to AlertDialog's Portal sub-component, even when the dialog is closed.

Screenshot 2024-09-04 at 12 50 08

Screenshot 2024-09-04 at 12 46 27 Screenshot 2024-09-04 at 12 46 13

Removing forceMount from Portal successfully fixed the behaviour, therefore I'm convinced there's an issue between forceMount and scroll-locking behaviours.

Expected behavior

Document body should not be scroll-locked when the AlertDialog is in closed state.

Reproducible example

Codesandbox repro

Suggested solution

Conditionally apply the scroll-locked behavior on open, instead of on mount of AlertDialog.

Additional context

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-alert-dialog 1.1.1
React n/a
Browser n/a
Assistive tech n/a
Node n/a
npm/yarn n/a
Operating System n/a
seedy commented 2 months ago

Turns out I can use CSS-only animations for my use-case. Hence, that bug is non-blocking to me ! 👌

lucashs94 commented 1 month ago

This happens even dont use Portal. The pointer-event: none is like a default property on radix