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

fix: check index routes against route config instead of id suffix #4560

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/remix-react/components.tsx
Expand Up @@ -1038,6 +1038,7 @@ export function useFormAction(
// TODO: Remove method param in v2 as it's no longer needed and is a breaking change
method: FormMethod = "get"
): string {
let { manifest } = useRemixEntryContext();
let { id } = useRemixRouteContext();
let resolvedPath = useResolvedPath(action ?? ".");

Expand All @@ -1048,7 +1049,7 @@ export function useFormAction(
// https://github.com/remix-run/remix/issues/927
let location = useLocation();
let { search, hash } = resolvedPath;
let isIndexRoute = id.endsWith("/index");
let isIndexRoute = manifest.routes[id].index;

if (action == null) {
search = location.search;
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-server-runtime/server.ts
Expand Up @@ -708,7 +708,7 @@ function isIndexRequestUrl(url: URL) {
function getRequestMatch(url: URL, matches: RouteMatch<ServerRoute>[]) {
let match = matches.slice(-1)[0];

if (isIndexRequestUrl(url) && match.route.id.endsWith("/index")) {
if (isIndexRequestUrl(url) && match.route.index) {
return match;
}

Expand Down