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

Not found page, component loses styles #53210

Closed
1 task done
andelkocvjetkovic opened this issue Jul 26, 2023 · 12 comments · Fixed by #53906
Closed
1 task done

Not found page, component loses styles #53210

andelkocvjetkovic opened this issue Jul 26, 2023 · 12 comments · Fixed by #53906
Assignees
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@andelkocvjetkovic
Copy link

andelkocvjetkovic commented Jul 26, 2023

Verify canary release

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

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103
    Binaries:
      Node: 20.2.0
      npm: 9.8.0
      Yarn: 3.2.3
      pnpm: 8.6.6
    Relevant Packages:
      next: 13.4.13-canary.3
      eslint-config-next: 13.4.12
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A

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

App Router

Link to the code that reproduces this issue or a replay of the bug

code: https://github.com/andelkocvjetkovic/nextjs-bug
link: https://nextjs-bug-tau.vercel.app/

To Reproduce

run

npm run build
npm  run start
  1. Click on button 'Not Found' which leads to not-found page.
  2. Click on button 'Home' which leads back to home page
Screen.Recording.2023-07-26.at.14.56.28.mov

Describe the Bug

When navigate back to Home page styles for the button are lost.

Expected Behavior

When navigate back to Home page styles for the button are not lost.

Which browser are you using? (if relevant)

Version 114.0.5735.248 (Official Build) (arm64)

How are you deploying your application? (if relevant)

next start and Varcel

NEXT-1507

@andelkocvjetkovic andelkocvjetkovic added the bug Issue was opened via the bug report template. label Jul 26, 2023
@pedroeckel
Copy link

pedroeckel commented Jul 26, 2023

I have the same problem here

@andelkocvjetkovic andelkocvjetkovic changed the title Not found page, component lost styles Not found page, component loses styles Jul 26, 2023
@andelkocvjetkovic
Copy link
Author

andelkocvjetkovic commented Jul 31, 2023

I think the issue is with the style links on the not-found page. Next.js loads the style links within the body, and then on the home page, the body content is replaced with the content of the home page, causing the links to get deleted.

Screenshot 2023-08-01 at 09 16 08

@kodiakhq kodiakhq bot closed this as completed in #53687 Aug 7, 2023
kodiakhq bot pushed a commit that referenced this issue Aug 7, 2023
Edge runtime doesn't have `/404` entry points as not-found, if server hits 404 it's hitting `/_not-found` entry point of edge bundles unlike nodejs server rendering.

In app-render it needs the information that when `pathname` (or can call `pagePath`) is `/404` it can render the `not-found.js` components properly

Separate the not-found test suite into 2 parts, a basic case testing all urls with `not-found.js` boundary, and another conflict route case with `not-found.js` with `not-found/` route at the same time

Fixes #53652
Fixes #53210
@andelkocvjetkovic
Copy link
Author

bug is still present.

@huozhi would you reopen this issues ?

@huozhi huozhi reopened this Aug 9, 2023
@huozhi huozhi added the linear: next Confirmed issue that is tracked by the Next.js team. label Aug 11, 2023
@huozhi huozhi self-assigned this Aug 11, 2023
@huozhi
Copy link
Member

huozhi commented Aug 14, 2023

@andelkocvjetkovic It's fixed in canary 13.4.14-canary.3, can you verify and we should be able to close this issue. And I added some tests in #53906 to ensure it won't be regression again

@andelkocvjetkovic
Copy link
Author

andelkocvjetkovic commented Aug 14, 2023

@huozhi 13.4.14-canary.3 version is not found.

Screenshot 2023-08-14 at 11 12 59 Screenshot 2023-08-14 at 11 14 47

@huozhi
Copy link
Member

huozhi commented Aug 14, 2023

@andelkocvjetkovic Can you try the latest canary?

@andelkocvjetkovic
Copy link
Author

andelkocvjetkovic commented Aug 14, 2023

I tried with 13.4.14-canary.5. The issue is still there.

@huozhi
Copy link
Member

huozhi commented Aug 14, 2023

Gonna take a deeper look on it 👁️

@MKraust
Copy link

MKraust commented Aug 18, 2023

We have similar issue. Navigating from 404, we lose some styles (exactly 1 css chunk is missing). But for us it happens only on hard navigation to 404 then soft navigation to other pages.

13.4.12 works fine for us, but newer versions are broken. I've traced this bug to 13.4.14-canary.4 (the first version with this bug for our project). I see that some people are having similar troubles with earlier versions, but I hope that this bit of info could help.

Unfortunately, I've been trying to reproduce it in a fresh project with no success (with the same versions it bugs in our project).

@andelkocvjetkovic
Copy link
Author

@huozhi I tried with 13.4.20-canary.2 and the issue is fixed.
https://nextjs-bug-tau.vercel.app

@huozhi
Copy link
Member

huozhi commented Aug 23, 2023

Looks like it's fixed in 13.4.19 already and the style is hoist properly after navigation. But one thing looks might not be reliable is that the style in the RSC payload showing precedence: "undefined". After discussing with react team we came out with 2 fixes (one on react side and one on nextjs side) so that this can make sure the link tags are marked as hoistable properly for react to handle. Then these similar kinds of cases can be avoid in the future

@kodiakhq kodiakhq bot closed this as completed in #53906 Aug 23, 2023
kodiakhq bot pushed a commit that referenced this issue Aug 23, 2023
### Problem

One style of `not-found` has `precendence` property with "undefined" value, which can't be handled by React Float, then during navigation the style could not load properly, lead to the style missing in issue #53210.

### Solution

Always enable `precendence` for all links, so all the css styles of page and convention components can be hoist by react properly. Float will decide which one should be handled. Previously this change only applies to template, actually we can apply it to all components so that they can all be handled properly especially during client navigation.

Related react change: facebook/react#27265
Fixes #53210
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

This closed issue has been automatically locked because it had no new activity for 2 weeks. 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 added the locked label Sep 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 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. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants