Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition exitDuration property not working correctly #6381

Open
1 of 2 tasks
andrew-stockdale-paytently opened this issue Jun 13, 2024 · 4 comments
Open
1 of 2 tasks
Labels
help wanted Contributions from community are welcome

Comments

@andrew-stockdale-paytently
Copy link

andrew-stockdale-paytently commented Jun 13, 2024

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

7.10.2

What package has an issue?

@mantine/core

What framework do you use?

Vite

In which browsers you can reproduce the issue?

Chrome

Describe the bug

The exit duration property doesn't seem to have any effect. With the following code, the span both mounts and unmounts in 1ms, rather than unmounting over 5s.

<Transition mounted={opened} duration={1} exitDuration={5000}> {(transitionStyles) => <span style={transitionStyles}>Open</span>} </Transition>

Removing the duration property results in both appearing and disappearing over the default 250ms.

Annoyingly, the codesandbox I've attached doesn't have the exact same issue, but after clicking the button a few times you'll see the transition timers end up in a strange state where the animation fades out instantly.

If possible, include a link to a codesandbox with a minimal reproduction

https://codesandbox.io/p/sandbox/mantine-react-template-forked-cxlrsn?file=%2Fsrc%2FApp.tsx%3A10%2C48

Possible fix

No response

Self-service

  • I would be willing to implement a fix for this issue
@rtivital rtivital added the help wanted Contributions from community are welcome label Jun 28, 2024
@michaelperros
Copy link
Contributor

I was unable to recreate this bug in Storybook, however, I cloned the Vite Mantine template and was able to recreate it there.

I will continue looking into it.

@rtivital
Copy link
Member

rtivital commented Aug 4, 2024

Might be related to react strict mode

@michaelperros
Copy link
Contributor

michaelperros commented Aug 5, 2024

The Vite template is not wrapped with StrictMode from what I understand. Additionally, I built it for production and started it with the preview script, and the bug still occurred. Would that rule out being related to strict mode?

I did discover that when it is behaving correctly the transition span successful mounts and unmounts from DOM as shown in the browser console inspector. This is true in Storybook, and also with the Vite Template if you remove exitDuration and only pass duration as a prop to Transition. In both these scenarios it works as expected.

However, if you pass both duration and exitDuration to Transition in the Vite template, the span does not unmount from the DOM at the end of the transition, and this is the scenario where the bug occurs.

I will continue looking into it.

@jared-jewitt
Copy link

Hey 👋 I'm on version 7.11.2 (using Vite) and am also experiencing this issue. My current workaround is to conditionally render the content based on the value I use for mounted:

<Transition mounted={mounted}>
  {styles => !mounted ? <></> : <div style={styles}>...</div>}
</Transition>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions from community are welcome
Projects
None yet
Development

No branches or pull requests

4 participants