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

[Bug?]: required <style> tag is removed on navigation #1401

Closed
2 tasks done
yume-chan opened this issue Mar 19, 2024 · 2 comments · Fixed by nksaraf/vinxi#282
Closed
2 tasks done

[Bug?]: required <style> tag is removed on navigation #1401

yume-chan opened this issue Mar 19, 2024 · 2 comments · Fixed by nksaraf/vinxi#282
Labels
bug Something isn't working vinxi related to vinxi

Comments

@yume-chan
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

If a <style> tag is (either directly or indirectly) referenced by both app.tsx and routes/a.tsx, but not referenced by routes/b.tsx, it will be removed when navigating from /a to /b.

I think this only happens in dev mode, because prod mode has a different style injection method.

Recording.2024-03-19.210830.mp4

Expected behavior 🤔

The <style> tag keeps there because app.tsx still requires it.

Steps to reproduce 🕹

Steps:

  1. Create a new Solid Start project using basic tempate
  2. Add <Counter/> to somewhere in app.tsx
  3. pnpm dev
  4. Click the About link in the top

Observation: the counter button loses its styling

Full repro: https://github.com/yume-chan/style-removed

Context 🔦

This is similar to #1191, although that issue might be caused by their specific configuration, the underlying problem truly exists.

It's not uncommon that the shell layout and some page both reference the same style, for example they both use a <Button> component which imports button.css.

If another page doesn't use that <Button> component, this <style> tag will be removed when navigating to that page, causing bad developer experiences.

The root cause might lay in vinxi, the style runtime might need to count the references to each style, and only remove them when not used. https://github.com/nksaraf/vinxi/blob/main/packages/vinxi/runtime/style.js

Your environment 🌎

## System:
 - OS: Windows 11 10.0.26040
 - CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
 - Memory: 4.49 GB / 31.91 GB
## npmPackages:
 - @solidjs/meta: ^0.29.2 => 0.29.3
 - @solidjs/router: ^0.13.1 => 0.13.1
 - @solidjs/start: ^0.7.6 => 0.7.6
 - solid-js: ^1.8.15 => 1.8.15
 - vinxi: ^0.3.10 => 0.3.10
@yume-chan yume-chan added the bug Something isn't working label Mar 19, 2024
@ryansolid ryansolid added the vinxi related to vinxi label Mar 19, 2024
nksaraf added a commit to nksaraf/vinxi that referenced this issue Jun 17, 2024
@zimonitrome
Copy link
Contributor

This is still not fully fixed.

I have a project with what I think is a valid set up but it is still bugged.

Demo repo

https://github.com/zimonitrome/solid_error_demo

Schema

This is how the app is set up.
The error disappears when either ref1 or ref2 are broken.

chrome_SUEdKbT7Mp

So CompB is always returned as a layout around the routes.

Video

chrome_Jcq5RQHkvN.mp4

@PalmDevs
Copy link

Hi, I am experiencing the same issue and can still reproduce using the repository in the comment above, even with up-to-date dependencies. Can somebody reopen this issue, or should I create a new issue entirely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vinxi related to vinxi
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants