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

feat: code group tab scrollIntoView #2355

Closed
wants to merge 2 commits into from

Conversation

izayl
Copy link

@izayl izayl commented May 10, 2023

add smooth scrollIntoView when code group is scrollable

@brc-dd
Copy link
Member

brc-dd commented May 10, 2023

Can you show a demo of what this does?

@izayl
Copy link
Author

izayl commented May 10, 2023

before

2023-05-10.23.47.30.mov

after

2023-05-10.23.49.07.mov

@brc-dd
Copy link
Member

brc-dd commented May 10, 2023

Ah, for some reason the scrolling isn't smooth if you click the left tab, and it does weird scrolling if one clicks the active tab.

Screen.Recording.2023-05-10.at.9.26.33.PM.mov

@brc-dd brc-dd added the theme Related to the theme label May 10, 2023
@izayl
Copy link
Author

izayl commented May 10, 2023

let me fix it

@izayl
Copy link
Author

izayl commented May 11, 2023

@brc-dd I found this is a bug of vitepress, see the recurrence demo, and I'll fix it in another pr

https://vitepress-codegroup-scroll-issue-izayl.vercel.app/markdown-examples.html

2023-05-11.15.09.40.mov

@izayl
Copy link
Author

izayl commented May 11, 2023

the scroll problem fixed at #2362

@izayl
Copy link
Author

izayl commented May 11, 2023

it now much better

2023-05-11.21.00.32.mov

@izayl
Copy link
Author

izayl commented May 16, 2023

@brc-dd I've made some changes to the code based on your feedback, and I'd appreciate it if you could take another look.

@brc-dd
Copy link
Member

brc-dd commented May 18, 2023

for some reason the scrolling isn't smooth if you click the left tab

This thing still doesn't appear to be fixed. For example click the last tab in your example (decode-array-primitive) -- it will scroll smoothly. Then click the first tab (decode-primitive) -- it won't scroll smoothly.

The fix at #2362 too isn't valid (left comment there). It will be better to not set scroll behavior smooth. Just something like this should be fine IMO:

label?.scrollIntoView({ block: 'nearest' })

@brc-dd brc-dd force-pushed the main branch 2 times, most recently from 7ad4a4e to f0d3082 Compare August 3, 2023 10:20
@brc-dd brc-dd closed this in 1a6efba Aug 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme Related to the theme
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants