Skip to content

Commit

Permalink
fix: Do not remove browse filters when going to dataset preview
Browse files Browse the repository at this point in the history
...to avoid jumping filters behavior. In this commit we also retrieve filters from previous query param to keep them defined.
  • Loading branch information
bprusinowski committed Nov 3, 2023
1 parent 82397c0 commit b028cde
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/browser/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import useEvent from "@/utils/use-event";
import { getFiltersFromParams } from "./filters";

export const getBrowseParamsFromQuery = (query: Router["query"]) => {
const values = mapValues(
const rawValues = mapValues(
pick(query, [
"type",
"iri",
Expand All @@ -25,16 +25,24 @@ export const getBrowseParamsFromQuery = (query: Router["query"]) => {
"order",
"search",
"dataset",
"previous",
]),
(v) => (Array.isArray(v) ? v[0] : v)
);

const { type, iri, subtype, subiri, topic, includeDrafts, ...values } =
rawValues;
const previous = values.previous ? JSON.parse(values.previous) : undefined;

return pickBy(
{
...values,
includeDrafts: values.includeDrafts
? JSON.parse(values.includeDrafts)
: false,
type: type ?? previous?.type,
iri: iri ?? previous?.iri,
subtype: subtype ?? previous?.subtype,
subiri: subiri ?? previous?.subiri,
topic: topic ?? previous?.topic,
includeDrafts: includeDrafts ? JSON.parse(includeDrafts) : undefined,
},
(x) => x !== undefined
);
Expand Down

0 comments on commit b028cde

Please sign in to comment.