-
-
Notifications
You must be signed in to change notification settings - Fork 803
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
fix: incorrect route generation for nested layout routes #1272
fix: incorrect route generation for nested layout routes #1272
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 52946f7. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
node.isVirtualParentRequired = | ||
removeGroups(node.path ?? '') | ||
.split('') | ||
.filter((char) => char === '/').length >= 2 && // check that the parent route wouldn't be the root route |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the "check that the parent route wouldn't be the root route " be simplified to this?
const node.parent?.parent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that this condition never comes to pass.
Since a nested layout route (with no .route.tsx
configuration file) wouldn't ever be detected as having a parent route because the routeNodes
array wouldn't already have a virtual parent route to link it to.
In the next chunk of code below is where a virtual parent route is created, the current route is added as its child, and the newly created parent node is mapped to the current node's .parent
prop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an alternative that works.
const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0
node.isVirtualParentRequired = node.isLayout
? !cleanedPathIsEmpty && !node.parent
: false
…riable segment reducing function
I fully acknowledge that this looks jank... there's no escaping this fact.
Most of it stems from having to short-circuit the
handleNode
function.Fixes #1150