-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issues loading CSS in default slots (#61428)
### What When using a default slot that re-exports another page, the CSS entries (and presumably other client reference modules, like JS entries) that correspond with the re-exported page won't be loaded, resulting in CSS styles not being applied. ### Why `next-app-loader` constructs the path to the default segment but special cases the `children` slot (which is used as the page), to mark the segment as an empty string. This is so that the parallel default file can be loaded. However the way that `defaultPath` is constructed, it assumes that `actualSegment` won't be an empty string, and constructs an invalid path like so: `app/example//default.tsx` When we go to look up the JS/CSS entries from the client reference manifest, the key will be incorrect and so it won't find the files for it, resulting in this bug. ### How This moves the `/` delimiting to be part of the creation of the `actualSegment` variable so that we only append it when we know we aren't setting it to be an empty string. Fixes #52245 Fixes #49871 Closes NEXT-2309 Closes NEXT-2310
- Loading branch information
Showing
7 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/parallel-routes-and-interception/app/default-css/@slot/default.tsx
This file contains 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,3 @@ | ||
export default function Default() { | ||
return null | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/parallel-routes-and-interception/app/default-css/@slot/more/page.tsx
This file contains 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,3 @@ | ||
export default function Page() { | ||
return <div>This is more</div> | ||
} |
1 change: 1 addition & 0 deletions
1
test/e2e/app-dir/parallel-routes-and-interception/app/default-css/default.tsx
This file contains 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 @@ | ||
export { default } from './page' |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/parallel-routes-and-interception/app/default-css/page.module.css
This file contains 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,3 @@ | ||
.red { | ||
color: red; | ||
} |
16 changes: 16 additions & 0 deletions
16
test/e2e/app-dir/parallel-routes-and-interception/app/default-css/page.tsx
This file contains 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,16 @@ | ||
import Link from 'next/link' | ||
import styles from './page.module.css' | ||
|
||
export default function Example() { | ||
return ( | ||
<div> | ||
<h1>Example</h1> | ||
<p className={styles.red} id="red-text"> | ||
This is red | ||
</p> | ||
<p> | ||
<Link href="/default-css/more">Show more</Link> | ||
</p> | ||
</div> | ||
) | ||
} |
This file contains 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