Skip to content

Add synced tabs persistence#2087

Merged
delucis merged 15 commits intowithastro:mainfrom
HiDeoo:hd-synced-tabs-persistence
Aug 16, 2024
Merged

Add synced tabs persistence#2087
delucis merged 15 commits intowithastro:mainfrom
HiDeoo:hd-synced-tabs-persistence

Conversation

@HiDeoo
Copy link
Copy Markdown
Member

@HiDeoo HiDeoo commented Jul 4, 2024

Closes #1851 and follow-up to #953.

This PR adds persistence to the synced tabs feature by relying on localStorage to store the synced tabs state.

This pull request is still a draft for 2 reasons:

  • There seems to be a flash of invalid tab that can randomly happen once in a while in development mode. I'd like to investigate this further and see if we can avoid it.
  • I want to play a bit more with the feature as most of the time so far has been spent on when/how to include the script to restore the synced tabs rather than actually using the feature.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jul 4, 2024

🦋 Changeset detected

Latest commit: ed1b3bf

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 Minor

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

@vercel

This comment was marked as outdated.

@github-actions github-actions bot added 📚 docs Documentation website changes 🌟 core Changes to Starlight’s main package labels Jul 4, 2024
@astrobot-houston
Copy link
Copy Markdown
Contributor

astrobot-houston commented Jul 4, 2024

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

Locale File Note
en guides/components.mdx Source changed, localizations will be marked as outdated.
en guides/customization.mdx Source changed, localizations will be marked as outdated.
en guides/site-search.mdx Source changed, localizations will be marked as outdated.
en manual-setup.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@HiDeoo
Copy link
Copy Markdown
Member Author

HiDeoo commented Aug 5, 2024

Undrafting this PR as I would like to get more eyes on it and have some people play with the changes, maybe during a T&D session or something similar.

The flash of invalid tabs that I mentioned is randomly present but only during dev like I mentioned and I'm not sure there is a reliable way to remove it. In production tho, I've never seen it but that's why I would like to have more people test it.

There is also probably room for improvements in the inline script but that could be done later on when we confirm that the current approach is working as expected.

@delucis delucis added the 🌟 minor Change that triggers a minor release label Aug 6, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 6, 2024

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit ed1b3bf
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/66bf1e6b6c3ed000082f7939
😎 Deploy Preview https://deploy-preview-2087--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: 92 (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.

Copy link
Copy Markdown
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.

Getting an early review in before we go through this on T&D on Thursday. Working great in the deploy preview for me @HiDeoo!

HiDeoo and others added 5 commits August 7, 2024 16:02
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com>
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com>
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com>
Copy link
Copy Markdown
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.

LGTM from an initial review! Look forward to seeing how testing goes tomorrow.

@HiDeoo
Copy link
Copy Markdown
Member Author

HiDeoo commented Aug 13, 2024

Based on the feedback during the T&D exploration, I've updated the PR:

  • We're now using a global symbol to keep track in Astro.locals if the restore script has been rendered or not. The goal is to avoid potential clash with user-defined variables in Astro.locals (even if unlikely).
  • I tried quite a few scenarios (embedded components, delayed components, etc.) to see if we could hit any issue with the restore script. So far, everything seems to work as expected no matter the scenario.

Copy link
Copy Markdown
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.

LGTM! Left two nits, but don’t have any “real” comments left!

Comment on lines +61 to +62
tabs?.[0]?.setAttribute('aria-selected', 'false');
tabs?.[0]?.setAttribute('tabindex', '-1');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit, but I think tabs will always be set here given it is declared as [...query]:

Suggested change
tabs?.[0]?.setAttribute('aria-selected', 'false');
tabs?.[0]?.setAttribute('tabindex', '-1');
tabs[0]?.setAttribute('aria-selected', 'false');
tabs[0]?.setAttribute('tabindex', '-1');

HiDeoo and others added 2 commits August 14, 2024 10:36
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com>
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com>
@delucis delucis merged commit caa84ea into withastro:main Aug 16, 2024
@astrobot-houston astrobot-houston mentioned this pull request Aug 16, 2024
Yoxnear pushed a commit to Yoxnear/starlight-custom that referenced this pull request Jul 23, 2025
Co-authored-by: Chris Swithinbank <357379+delucis@users.noreply.github.com>
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
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 📚 docs Documentation website changes 🌟 minor Change that triggers a minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants