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.tsx not using layout.tsx in "Route Groups" #53694

Closed
1 task done
Yovach opened this issue Aug 7, 2023 · 3 comments · Fixed by #53703
Closed
1 task done

not-found.tsx not using layout.tsx in "Route Groups" #53694

Yovach opened this issue Aug 7, 2023 · 3 comments · Fixed by #53703
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@Yovach
Copy link
Contributor

Yovach commented Aug 7, 2023

Verify canary release

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

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Tue Jul 18 21:28:32 UTC 2023
Binaries:
  Node: 20.4.0
  npm: 9.7.2
  Yarn: 1.22.19
  pnpm: 8.6.11
Relevant Packages:
  next: 13.4.14-canary.0
  eslint-config-next: N/A
  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

https://github.com/Yovach/nextjs-no-layout-on-not-found

To Reproduce

1 - Clone
2 - npm install
3 - npm run dev
4 - Go to http://localhost:3000/blog

Describe the Bug

The ./src/app/(public)/not-found.tsx isn't using the Root Layout of (public) folder.

app
  (admin)
    - layout.tsx
    - page.tsx
  (public)
    /blog
      - page.tsx
    - layout.tsx
    - not-found.tsx
    - page.tsx

Expected Behavior

The ./src/app/(public)/not-found.tsx file should use the Root Layout of (public) folder, as it's in the same route group and should consider ./src/app/(public) to be the root of its tree.

So when we visit http://localhost:3000/blog, we should get "Welcome to public page !" followed by "Not found!"

It was working on v13.4.9 but according to a Next.js user, a v13.4.10 canary version broke this feature :(

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1499

@Yovach Yovach added the bug Issue was opened via the bug report template. label Aug 7, 2023
@mburumaxwell
Copy link

Could this be what is requested for at #50034 ?

@huozhi huozhi added the linear: next Confirmed issue that is tracked by the Next.js team. label Aug 7, 2023
@Yovach
Copy link
Contributor Author

Yovach commented Aug 7, 2023

Could this be what is requested for at #50034 ?

Yes, probably, it worked with v13.4.9 but seems to be broken now.

@kodiakhq kodiakhq bot closed this as completed in #53703 Aug 12, 2023
kodiakhq bot pushed a commit that referenced this issue Aug 12, 2023
…ary (#53703)

### What?

We change the not-found rendering strategy to the origin one which recovers the not found error from the flight data, and hit the error boundary to display the closet not found component.

For parallel `@slot` we shouldn't pass down the not-found boundary, the boundary is only for `@children`.

### Why?

We're having a lot of not-found matching issues that manually searching for not found and layout won't be accurate as we have various scenarios like `(group)` routes, dynamic routes, etc.

### How?

Only render html with empty body so that the error can recover from flight and render the proper not-found component during hydration.

One change for metadata is that we need to get the "not-found" metadata in the initial render, so we'll catch the not-found error once there first and start render the "not-found" metadata and put it in the flight data. Then when it recovers it's still preserved.

Fixes #53694
@github-actions
Copy link
Contributor

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 locked as resolved and limited conversation to collaborators Aug 26, 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.

3 participants