-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: Ignore pathless layout routes when matching actions #4376
Conversation
🦋 Changeset detectedLatest commit: e88ce64 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
function getPathContributingMatches(matches: ClientMatch[]) { | ||
return matches.filter( | ||
(match, index) => | ||
index === 0 || | ||
(!match.route.index && match.route.path && match.route.path.length > 0) | ||
); |
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.
Copied from what we use in react-router to trim routes that do not contribute to the path
if (!isIndexRequestUrl(url) && match.route.index) { | ||
return matches.slice(-2)[0]; | ||
if (isIndexRequestUrl(url) && match.route.index) { | ||
return match; |
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.
Return the leaf for index requests, otherwise return the lowest path contributing match
} | ||
|
||
return match; | ||
return getPathContributingMatches(matches).slice(-1)[0]; |
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.
Same change on the server
@@ -590,7 +590,7 @@ export function createTransitionManager(init: TransitionManagerInit) { | |||
invariant(matches, "No matches found"); | |||
if (fetchControllers.has(key)) abortFetcher(key); | |||
|
|||
let match = getFetcherRequestMatch( | |||
let match = getRequestMatch( |
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.
We now use the same util for action submissions
and fetchers - so we only do this ?index
/pathless
logic once
🤖 Hello there, We just published version Thanks! |
* fix: Ignore pathless layout routes when matching actions * Add changeset * Add comment * Remove deuped function
Same fix as remix-run/react-router#9455 in react router
If you have a route tree of:
And a
<Form method="post">
in<Parent />
submits, then it should ignore the pathless layout route in the middle and walk upwards to the last path-contributing matches action.Closes: #2498
Testing Strategy: Added integration tests