[bug]: Can't scroll to a section with an id using Link comp inside both Sheet and Drawer
Describe the bug
I'm working on a landing page and I want to add the posibility to navigate between page sections using links and sections Id, but when I start working on responsive I used sheet and when I add links inside it, when the sheet closed I had an expected scrolling to top. So I try to use Drawer insted but drawer doesn't scroll at all.
Affected component/components
Drawer, Sheet
How to reproduce
- Create a page and include some sections with id.
- Create a sidebar using sheet or drawer
- Add some links inside them and in the href add #section_id, and each link should be inside a DrawerClose or SheetClose
Source Code Issue Link
https://github.com/ahmedkhabar/shadcn-issue
Logs
No response
System Info
Windows 10 64 bit
Microsoft Edge
NextJS 14
App Router
Before submitting
- [X] I've made research efforts and searched the documentation
- [X] I've searched for existing issues
+1
@ahmedkhabar how did you fix this issue?
I shared the solution for that here: https://github.com/shadcn-ui/ui/discussions/2127#discussioncomment-9168116
I shared the solution for that here: #2127 (comment)
Does this solution also work for the Drawer? I tried it, but my page still doesn't scroll.
I shared the solution for that here: #2127 (comment)
don't work for the Drawer
I've found a fix for the drawer.
What I did was a bit overkill. I don't think it was necessary, but the magic is using a delay. I created a context provider. But I think this code can help people who want a drawer to be working with scroll to section.
See code below: