emilkowalski / vaul

A drawer component for React.
https://vaul.emilkowal.ski
MIT License
6.45k stars 215 forks source link

Option to disable scrolling back to drawer trigger #512

Open SimonVillage opened 3 days ago

SimonVillage commented 3 days ago

I have anchor links in my drawer which should scroll the page to a certain id / position.

On Safari the scroll does not happen if position: fixed !important! is applied to the body. A noBodyStyles={true} on the root fixes this problem but also changes the general behavior which I would like to avoid.

Another problem is that if the drawer is closed, the page will scroll back to the position where the trigger is. A preventScrollRestoration={true} does not solve the problem.

Here is an example with: <Drawer.Root preventScrollRestoration={true} noBodyStyles={true}>

https://github.com/user-attachments/assets/83b53847-708e-49d7-bf54-539955c9f05d