Skip to content

[Dialog] Various issues when combining with Framer Motion (forceMount related) #2023

@swernerx

Description

@swernerx

Bug report

Current Behavior

Working with animation on libraries like Framer Motion the docs suggest to use the forceMount flag. The Dialog component seems to have a few issues with this:

  • pointer-events: none is applied to both document.body and overlay when forceMount is enabled. This prevents any interaction with the actual application (even initially opening the dialog). It does not care about the actual value of the open property passed with the Root component.
  • Setting modal=false on Root fixes these two pointer-event related issues but messes with the overlay component. It never mounts the overlay... never. Not even when forceMount is true.

Expected behavior

  • pointer-event should only be applied when the dialog is open ... independent from the actual mount scenario relying on the open state/prop.
  • modal: false should still mount the overlay when forceMount is true.

Reproducible example

CodeSandbox Demo

Suggested solution

I have not checked the code in detail but I guess with a small number of tweaks in the logic it should be done... Hopefully not breaking other expected behavior. I also would suggest to add a full blown working demo using an animation library like framer-motion to the docs.

Additional context

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-dialog 1.0.3
React n/a 18.2.0
Browser Chrome 110
Assistive tech - -
Node n/a 16.19.1
npm/yarn pnpm 7.29.0
Operating System

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions