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

[bug]: Can't scroll to a section with an id using Link comp inside both Sheet and Drawer #3536

Open
2 tasks done
ahmedkhabar opened this issue Apr 19, 2024 · 6 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@ahmedkhabar
Copy link

ahmedkhabar commented Apr 19, 2024

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.
Screenshot (54)
Screenshot (55)

Affected component/components

Drawer, Sheet

How to reproduce

  1. Create a page and include some sections with id.
  2. Create a sidebar using sheet or drawer
  3. 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

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@ahmedkhabar ahmedkhabar added the bug Something isn't working label Apr 19, 2024
@hrishikeshmane
Copy link

+1

@hrishikeshmane
Copy link

@ahmedkhabar how did you fix this issue?

@ahmedkhabar
Copy link
Author

I shared the solution for that here: #2127 (comment)

@dpkmi
Copy link

dpkmi commented May 29, 2024

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.

@tittobreno
Copy link

tittobreno commented May 30, 2024

I shared the solution for that here: #2127 (comment)

don't work for the Drawer

@dpkmi
Copy link

dpkmi commented May 30, 2024

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:

Scherm­afbeelding 2024-05-30 om 10 22 46
Scherm­afbeelding 2024-05-30 om 10 22 55
Scherm­afbeelding 2024-05-30 om 10 23 10
Scherm­afbeelding 2024-05-30 om 10 23 19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants