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

Automated layout nesting always inheriting from root.tsx when overridden #9496

Open
Mardoxx opened this issue May 27, 2024 · 2 comments
Open
Labels

Comments

@Mardoxx
Copy link

Mardoxx commented May 27, 2024

Reproduction

The use case here is, user wants pages to default to using a default layout. Alternatively certain pages should use their own defined template.

Reading https://remix.run/docs/en/main/file-conventions/routes#nested-urls-without-layout-nesting it seems you should be able to override the default layouts.

https://stackblitz.com/edit/remix-run-remix-jdvbmm?file=app%2Froutes%2F_auth.loginfoo_.tsx

If you go to /login or /loginfoo both still inherit from root.tsx

Perhaps I have misunderstood.

To conceptualise, imagine all pages to require a header, besides the login and about page -- without using a conditional rendering in the root.tsx template..

System Info

See stackblitz

Used Package Manager

npm

Expected Behavior

Not to use root.tsx on overridden layout.

Actual Behavior

Uses root.tsx on overridden layout.

@Mardoxx Mardoxx changed the title Automated layout nesting always inheriting from root.tsx Automated layout nesting always inheriting from root.tsx when overridden May 27, 2024
@machour machour added the docs label May 28, 2024
@machour
Copy link
Collaborator

machour commented May 28, 2024

The behaviour you are seeing is the expected one. Perhaps a note should be added to the docs explaining that everything will be always nested under root.

The trick is to either switch the layout in root depending on the location (useLocation), or leave the root as simple as possible (make it only render the shared parts) and use pathless routes (the section right below the one you linked)

@topaxi
Copy link

topaxi commented May 31, 2024

I also ran into this, the docs seemed to be a bit misleading here. Our case is similar, where only a single page should opt out of the default layout, easy to handle within the root route via a route handle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants