rive-app / rive-react

React runtime for Rive

Home Page:https://rive-app.github.io/rive-react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Render problem in NextJS when using Chakra UI's Drawer component

felipesses opened this issue · comments

Hi, I am using NextJs and Chakra UI in my project and I'm having some issues with the Rive Component. Here's the issue:

Gravacao.de.Tela.2023-03-23.as.19.47.38.mov

When I close the Drawer and open it again, the canvas height and width are setting to 0px automatically

before:
Captura de Tela 2023-03-22 às 10 49 37

after closing and reopening:
Captura de Tela 2023-03-22 às 10 50 08

This is happening with other .riv files aswell.

I can observe the same behaviour when using the Popover component from Chakra UI with the prop isLazy. By default it only renders the popover content when it is open. The content container get's removed from DOM when the popover is closed. This seems to be the culprit here.

I can tell Chakra UI to keep the container mounted after the popover was initially opened (using lazyBehavior="keepMounted"). This fixes the problem and serves as a workaround for me at the moment (though it's not ideal when you need the unmounting behaviour to save performance).

Unfortunately, the Drawer component doesn't seem to have such prop according to the docs 😕.

I can observe the same behaviour when using the Popover component from Chakra UI with the prop isLazy. By default it only renders the popover content when it is open. The content container get's removed from DOM when the popover is closed. This seems to be the culprit here.

I can tell Chakra UI to keep the container mounted after the popover was initially opened (using lazyBehavior="keepMounted"). This fixes the problem and serves as a workaround for me at the moment (though it's not ideal when you need the unmounting behaviour to save performance).

Unfortunately, the Drawer component doesn't seem to have such prop according to the docs 😕.

thanks for the reply! do you have any possible workaround or ideas that I could try?