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

Fixes a style issue of client:only components in DEV mode during view transitions. #10532

Merged
merged 3 commits into from
Mar 22, 2024

Conversation

martrapp
Copy link
Member

Changes

fixes #10466

Originally fixed for client:only components that use transition:persist in #8840.
It turns out that the styles were also missing when navigating back to pages with non-persisted client:only components.

Testing

e2e tests successful

Docs

bug fix, n.a.

Copy link

changeset-bot bot commented Mar 22, 2024

🦋 Changeset detected

Latest commit: b1e2403

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

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 pkg: astro Related to the core `astro` package (scope) label Mar 22, 2024
Comment on lines -710 to +705
const style = document.head.querySelector(`style[${VITE_ID}="${id}"]`);
const style = nextHead.querySelector(`style[${VITE_ID}="${id}"]`);
Copy link
Member Author

@martrapp martrapp Mar 22, 2024

Choose a reason for hiding this comment

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

Instead of copying the styles from the previous page, we now copy from the iframe. This also works for non-persisted client:only components.

Comment on lines -699 to -703
// Clear former persist marks
document.head
.querySelectorAll(`style[${PERSIST_ATTR}=""]`)
.forEach((s) => s.removeAttribute(PERSIST_ATTR));

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a remnant of an earlier approach.

@martrapp martrapp merged commit 8306ce1 into main Mar 22, 2024
13 checks passed
@martrapp martrapp deleted the mt/onlystyles branch March 22, 2024 14:36
@astrobot-houston astrobot-houston mentioned this pull request Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
2 participants