-
Notifications
You must be signed in to change notification settings - Fork 282
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(astro,clerk-js): View transitions support #4342
Conversation
🦋 Changeset detectedLatest commit: 7915b29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
!snapshot |
Hey @wobsoriano - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
* For more info on the issue, see: | ||
* https://github.com/withastro/astro/issues/11000 | ||
*/ | ||
__internal_flushEmotionCache() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikosdouvlis asking in advance here if there's a better way to access the internal emotion cache rather than what I did here. Any advice would do!
Issue: With Astro's View Transitions, navigating to a new page removes unnecessary head elements, including the emotion cache. Clearing the cache resolves this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this adds 140KB to the bundle size so this is not a good solution
componentsControls.flushEmotionCache = () => { | ||
emotionCache.sheet.flush(); | ||
emotionCache.inserted = {}; | ||
emotionCache.registered = {}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got the idea here
document.addEventListener('astro:page-load', async () => { | ||
await runInjectionScript(${JSON.stringify(internalParams)}); | ||
})`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and astro:before-swap
runs only on view transition enabled pages. This will run on load and every page navigation.
It mounts all Clerk components in the new document.
document.addEventListener('astro:before-swap', async e => { | ||
window.Clerk.__internal_flushEmotionCache(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change