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

Recently fixed CSS ordering issue is re-corrupted on hot reload #48807

Closed
1 task done
miketdonahue opened this issue Apr 25, 2023 · 2 comments · Fixed by #49010
Closed
1 task done

Recently fixed CSS ordering issue is re-corrupted on hot reload #48807

miketdonahue opened this issue Apr 25, 2023 · 2 comments · Fixed by #49010
Labels
bug Issue was opened via the bug report template.

Comments

@miketdonahue
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
    Platform: darwin
    Arch: x64
    Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64
Binaries:
    Node: 18.12.1
    npm: 8.19.2
    Yarn: 3.5.0
    pnpm: 8.1.1
Relevant packages:
    next: 13.3.2-canary.5
    eslint-config-next: 13.3.0
    react: 18.2.0
    react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue

https://github.com/meebix/repro-nextjs-css-order

To Reproduce

  1. Load the app at http://localhost:3000
  2. Notice the styled button when the page loads
  3. Using your editor (VSCode), save the page.tsx file which will trigger a hot-reload of the dev server
  4. Notice the button has disappeared

Describe the Bug

When the Next dev server performs a hot reload, the CSS ordering is corrupted. The original CSS ordering issue in Next.js was recently fixed via this PR. However, it appears there is more to the issue, which I am raising. (CC @shuding who fixed the original issue 🙏🏻 )

You can see from my screenshots that on initial load of the page, the CSS ordering is correct:
correct-css-order

However, after a hot-reload, the ordering is corrupted:
hot-reload-corrupt-css-order

In my repro, the Button disappears because in the layout CSS there is button reset CSS and thus it must come first before any page CSS.

Expected Behavior

When the Next dev server performs a hot-reload, the CSS order should be maintained and thus not corrupted.

Which browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

No response

@miketdonahue miketdonahue added the bug Issue was opened via the bug report template. label Apr 25, 2023
@philwolstenholme
Copy link
Contributor

#47585 was the original ticket

@kodiakhq kodiakhq bot closed this as completed in #49010 Apr 30, 2023
kodiakhq bot pushed a commit that referenced this issue Apr 30, 2023
Closes #48807.

The issue seems to be introduced with recent React Float change, which isn't a real problem but a behavior change. Resources are layered by the `precedence` key and the style insertion logic can be simplified as "insert the new stylesheet right after the existing stylesheet in the same layer". When multiple stylesheets are inserted in the same render pass, their new order will be flipped.

This is a nice feature so we can always maintain the order of resources that might conflict.
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants