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

Add instant behavior to synced tab scrolling #2747

Merged
merged 3 commits into from
Jan 6, 2025
Merged

Conversation

bbag
Copy link
Contributor

@bbag bbag commented Jan 2, 2025

Description

  • Closes: Smooth scrolling on window causes synced tab positions to jump #2746

  • What does this PR change? Give us a brief description.
    This ensures the scroll behavior will be instant as expected whenever clicking a synced tab triggers a window scroll, which fixes the odd "smooth scroll jump" on Starlight sites which use html { scroll-behavior: smooth; } in their global CSS. This provides a nicer UX on sites which use smooth scrolling, where e.g. clicking an item in the ToC smooth scrolls to that section on the page, but clicking a new synced tab doesn't cause an awkward jump as it scrolls to the new tab's position. It should be a non-breaking change to existing Starlight sites since the default scroll behavior is already instant. 🙂

  • Did you change something visual? A before/after screenshot can be helpful.
    Nope, just a tiny quality-of-life improvement for tabs on pages which use smooth scrolling!

This forces the scroll behavior to be instant whenever clicking a synced tab triggers a window scroll, which fixes the odd "smooth scroll jump" on Starlight sites which use `html { scroll-behavior: smooth; }` in their global CSS. This provides a nicer UX on sites which use smooth scrolling, where e.g. clicking an item in the ToC smooth scrolls to that section on the page, but clicking a new synced tab doesn't cause an awkward jump as it scrolls to the new tab's position. It should be a non-breaking change to existing Starlight sites since the default scroll behavior of the window is already instant. 🙂
Copy link

changeset-bot bot commented Jan 2, 2025

🦋 Changeset detected

Latest commit: 7128ed6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Jan 2, 2025
Copy link

netlify bot commented Jan 2, 2025

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 7128ed6
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/677c2d69a99101000829c05a
😎 Deploy Preview https://deploy-preview-2747--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@astrobot-houston
Copy link
Collaborator

Hello! Thank you for opening your first PR to Starlight! ✨

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Netlify 🤩

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @bbag! I think this change is fair. There’s no easy way for someone to fix this on their end if using smooth scrolling. We did evaluate smooth scrolling for stuff as a default and felt it can actually slow down the docs UX, so decided against it, but I think guaranteeing this behaviour works as expected even when someone has opted in to smooth scrolling makes sense 👍

@delucis delucis added the 🌟 patch Change that triggers a patch release label Jan 6, 2025
@delucis delucis linked an issue Jan 6, 2025 that may be closed by this pull request
1 task
@delucis delucis merged commit 474c27e into withastro:main Jan 6, 2025
15 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Jan 6, 2025
@bbag
Copy link
Contributor Author

bbag commented Jan 8, 2025

@delucis Awesome, I appreciate it! I'm building my company's docs site with Starlight as we speak and loving it, and this little tweak will come in clutch for us (and hopefully others in the future as well). 🙂

The Astro team is next level, thanks for everything y'all do. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 core Changes to Starlight’s main package 🌟 patch Change that triggers a patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smooth scrolling on window causes synced tab positions to jump
3 participants