Skip to content

Include search params in toolpad navigation #4537

@ckopsa

Description

@ckopsa

I attempted to use a link that included search params in the global navigation for toolpad, but it was slicing of the search params.

/jobs?page=2 --> /jobs

Here is the diff that solved my problem:

diff --git a/node_modules/@toolpad/core/shared/Link.js b/node_modules/@toolpad/core/shared/Link.js
index cfe8842..a50dba5 100644
--- a/node_modules/@toolpad/core/shared/Link.js
+++ b/node_modules/@toolpad/core/shared/Link.js
@@ -21,7 +21,7 @@ export const Link = /*#__PURE__*/React.forwardRef(function Link(props, ref) {
     return event => {
       event.preventDefault();
       const url = new URL(event.currentTarget.href);
-      routerContext.navigate(url.pathname, {
+      routerContext.navigate(url.pathname + url.search, {
         history
       });
       onClick?.(event);

Search keywords:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions