Skip to content

Commit

Permalink
Fix query params routing for tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWatenbergScality committed Dec 24, 2024
1 parent 8e6d0db commit 8d0053f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.49.2",
"react-query": "^3.34.0",
"react-router": "^7.0.1",
"react-router-dom": "^7.0.1",
"react-router": "7.0.1",
"react-router-dom": "7.0.1",
"react-select": "4.3.1",
"react-table": "^7.7.0",
"react-test-renderer": "^18.3.1",
Expand Down
12 changes: 9 additions & 3 deletions src/lib/components/tabsv2/Tabsv2.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Routes,
useLocation,
useNavigate,
useRoutes,
} from 'react-router';
import styled from 'styled-components';
import { ButtonIcon } from '../buttonv2/Buttonv2.component';
Expand Down Expand Up @@ -115,10 +116,10 @@ function Tabs({
filteredTabsChildren.forEach((child, index) => {
const isSelected =
!!matchPath(
location.pathname,
child.props.path.startsWith('/')
(child.props.path.startsWith('/')
? child.props.path
: url + '/' + child.props.path,
: url + '/' + child.props.path) + '*',
location.pathname,
) && (child.props.query ? matchQuery(child.props.query) : true);

if (isSelected) {
Expand All @@ -140,6 +141,7 @@ function Tabs({
handleKeyDown,
displayScroll,
} = useScrollingTabs(selectedTabIndex);

const tabItems = filteredTabsChildren.map((child, index) => {
const {
path,
Expand Down Expand Up @@ -225,6 +227,10 @@ function Tabs({
{filteredTabsChildren.map((tab, index) => {
const path = tab.props.path.split('/').pop();

if (tab.props.query && !matchQuery(tab.props.query)) {
return <></>;
}

return (
<Route
key={index}
Expand Down

0 comments on commit 8d0053f

Please sign in to comment.