Skip to content

notFound in 'fuzzy' mode does not behave as expected #2929

@bhainesva

Description

@bhainesva

Which project does this relate to?

Router

Describe the bug

I'm referencing the documentation for the fuzzy notFoundMode option here: https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#notfoundmode-fuzzy.

This is the process it describes for handling a notFound() error:

The nearest suitable route is found using the following criteria:

  • The route must have children and therefore an Outlet to render the notFoundComponent
  • The route must have a notFoundComponent configured or the router must have a defaultNotFoundComponent configured

For the example from the documentation the described expected behavior is:

The notFoundComponent of the posts route will be rendered because it is the nearest suitable parent route with children (and therefore an outlet) and a notFoundComponent configured.

In testing I'm seeing the notFoundComponent of the $postId route rendered even though it doesn't have children/an Outlet. The actual behavior makes more sense to me than the described behavior, this might be a bug with the documentation or my understanding of it rather than with the library.

Your Example Website or App

https://stackblitz.com/edit/github-b3gtgj-hayvly

Steps to Reproduce the Bug or Issue

  1. Go to https://stackblitz.com/edit/github-b3gtgj-hayvly
  2. Click the Posts nav link
  3. Click any link in the list of post ids
  4. See that what is rendered is the $postId.notFoundComponent in the Outlet of the posts route.

Expected behavior

In step 4 I expect to see posts.notFoundComponent, not $postId.notFoundComponent.

Screenshots or Videos

No response

Platform

  • OS: macOs
  • Browser: Firefox
  • Version: 1.85.5

Additional context

I searched for and found these related issues, which I believe are describing separate problems:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions