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 focus issue in component filter, view filters when >1 filters applied #1808

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/componenten/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ keywords:
---

import { ComponentOverview } from "@site/src/components/ComponentOverview";
import BrowserOnly from "@docusaurus/BrowserOnly";

# Componenten

De componenten van NL Design System worden met een [estafette aanpak](/handboek/estafettemodel) gemaakt en kunnen dus verschillende statussen hebben.

<ComponentOverview headingLevel={2} />
<BrowserOnly>{() => <ComponentOverview headingLevel={2} />}</BrowserOnly>
14 changes: 9 additions & 5 deletions src/components/ComponentOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { PropSidebarItem, PropSidebarItemLink } from '@docusaurus/plugin-content-docs';
import { useHistory } from '@docusaurus/router';
import { useCurrentSidebarCategory } from '@docusaurus/theme-common';
import { useDocById } from '@docusaurus/theme-common/internal';
import componentProgress from '@nl-design-system/component-progress/dist/index.json';
Expand All @@ -24,8 +23,7 @@ export const ComponentOverview = () => {
};

const category = useCurrentSidebarCategory();
const { location, push } = useHistory();

const { location } = window;
const params = new URLSearchParams(location.search);

const getComponent = (item: PropSidebarItemLink) =>
Expand Down Expand Up @@ -105,7 +103,13 @@ export const ComponentOverview = () => {
params.append(SEARCH_PARAM, SEARCH_VALUES.ONLY_IMPLEMENTED);
}

push({ ...location, search: params.toString() });
if (params.size > 0) {
history.pushState({}, '', `?${params.toString()}`);
} else {
const url = new URL(window.location.href);
url.searchParams.delete('filter');
history.pushState({}, '', url);
}
}, [showTodo, showHelpWanted, showCommunity, showCandidate, showHallOfFame, showOnlyImplemented]);

const todo = components.filter((c) => c.relayStep === 'UNKNOWN');
Expand All @@ -127,7 +131,7 @@ export const ComponentOverview = () => {
{
className: 'utrecht-accordion--nlds-subtle',
headingLevel: 2,
expanded: false,
expanded: params.size > 0,

// TODO: Make Pull Request for Utrecht Accordion to allow `ReactNode`
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Loading