Skip to content

router: buildLocation non-changing route with index route #4580

Closed
@checkerschaf

Description

@checkerschaf

Which project does this relate to?

Router

Describe the bug

When using this code to do a search param change on the current page, the route is changing incorrectly:

navigate({
  to: ".",
  search: (prev) => ({
    ...prev,
    [`_${name}`]: open ? true : undefined,
  }),
  resetScroll: false,
});

Your Example Website or App

https://github.com/checkerschaf/tanstack-start-buildlocation-bug

Steps to Reproduce the Bug or Issue

  1. Go to http://localhost:3000/en/hello
  2. Press the top Add test button
  3. The url should stay the same, but it changes to /en instead

Expected behavior

The url should stay http://localhost:3000/en/hello and append ?_test=true as a search param

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.125.1
  • OS: macOS
  • Browser: Chrome
  • Browser Version: latest
  • Bundler: vite

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions