-
Notifications
You must be signed in to change notification settings - Fork 30k
Fix not found css not being preloaded while navigation #53906
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d60ed40
Fix not found css not being preloaded while navigation
huozhi 220c865
revert
huozhi 7467f72
404 page
huozhi 10e847c
mark all as precedence=next
huozhi ea052d6
move test case
huozhi 9ec1222
update test
huozhi 774572b
update test
huozhi cbb756e
revert
huozhi 89a0335
fix resolution
huozhi 6e459e6
always use next precedence, update tests
huozhi 51bac02
fix
huozhi 1fa808c
revert dev precedence
huozhi f7e562e
fix test
huozhi e20329e
Merge branch 'canary' into fix/not-found-styles-navigation
huozhi ef80325
Merge branch 'canary' into fix/not-found-styles-navigation
kodiakhq[bot] df1f51b
Merge branch 'canary' into fix/not-found-styles-navigation
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export default function Layout({ children }) { | ||
| return ( | ||
| <html> | ||
| <body>{children}</body> | ||
| </html> | ||
| ) | ||
| } |
23 changes: 23 additions & 0 deletions
23
test/e2e/app-dir/not-found/css-precedence/app/not-found.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 'use client' | ||
|
|
||
| import { Button } from '../components/button/button' | ||
| import { useRouter } from 'next/navigation' | ||
|
|
||
| function NotFound() { | ||
| const router = useRouter() | ||
| return ( | ||
| <div> | ||
| <h1>404 - Page Not Found</h1> | ||
| <Button | ||
| id="go-to-index" | ||
| onClick={() => { | ||
| router.push('/') | ||
| }} | ||
| > | ||
| Home | ||
| </Button> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default NotFound |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| 'use client' | ||
|
|
||
| import { useRouter } from 'next/navigation' | ||
| import { Button } from '../components/button/button' | ||
|
|
||
| export default function Page() { | ||
| const router = useRouter() | ||
| return ( | ||
| <> | ||
| <Button | ||
| id="go-to-404" | ||
| onClick={() => { | ||
| router.push('/404') | ||
| }} | ||
| > | ||
| Not Found | ||
| </Button> | ||
| </> | ||
| ) | ||
| } |
12 changes: 12 additions & 0 deletions
12
test/e2e/app-dir/not-found/css-precedence/components/button/button.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| 'use client' | ||
|
|
||
| import styles from './button.module.css' | ||
| import React from 'react' | ||
|
|
||
| export const Button = ({ children, ...props }) => { | ||
| return ( | ||
| <button {...props} className={styles.button}> | ||
| {children} | ||
| </button> | ||
| ) | ||
| } |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/not-found/css-precedence/components/button/button.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .button { | ||
| border: 1px solid #ccc; | ||
| border-radius: 4px; | ||
| background: rgb(0, 128, 0); | ||
| color: #fff; | ||
| padding: 8px 16px; | ||
| } |
20 changes: 20 additions & 0 deletions
20
test/e2e/app-dir/not-found/css-precedence/components/navigate-404-section.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| 'use client' | ||
|
|
||
| import { Button } from './button/button' | ||
| import { useRouter } from 'next/navigation' | ||
|
|
||
| export default function Navigate404Section() { | ||
| const router = useRouter() | ||
| return ( | ||
| <p> | ||
| <Button | ||
| id="go-to-navigate-404" | ||
| onClick={() => { | ||
| router.push('/navigate-404') | ||
| }} | ||
| > | ||
| Go to /navigate-404 | ||
| </Button> | ||
| </p> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { createNextDescribe } from 'e2e-utils' | ||
| import { check } from 'next-test-utils' | ||
|
|
||
| createNextDescribe( | ||
| 'app dir css', | ||
| { | ||
| files: __dirname, | ||
| skipDeployment: true, | ||
| dependencies: { | ||
| sass: 'latest', | ||
| }, | ||
| }, | ||
| ({ next }) => { | ||
| it('should load css while navigation between not-found and page', async () => { | ||
| const browser = await next.browser('/') | ||
| await check( | ||
| async () => | ||
| await browser.eval( | ||
| `window.getComputedStyle(document.querySelector('#go-to-404')).backgroundColor` | ||
| ), | ||
| 'rgb(0, 128, 0)' | ||
| ) | ||
| await browser.elementByCss('#go-to-404').click() | ||
| await browser.waitForElementByCss('#go-to-index') | ||
| await check( | ||
| async () => | ||
| await browser.eval( | ||
| `window.getComputedStyle(document.querySelector('#go-to-index')).backgroundColor` | ||
| ), | ||
| 'rgb(0, 128, 0)' | ||
| ) | ||
| await browser.elementByCss('#go-to-index').click() | ||
| await browser.waitForElementByCss('#go-to-404') | ||
| await check( | ||
| async () => | ||
| await browser.eval( | ||
| `window.getComputedStyle(document.querySelector('#go-to-404')).backgroundColor` | ||
| ), | ||
| 'rgb(0, 128, 0)' | ||
| ) | ||
| }) | ||
| } | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.