From b028cde8b275b6f06bf1b685a65e573628f1a174 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Fri, 3 Nov 2023 11:05:43 +0100 Subject: [PATCH] fix: Do not remove browse filters when going to dataset preview ...to avoid jumping filters behavior. In this commit we also retrieve filters from previous query param to keep them defined. --- app/browser/context.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/browser/context.tsx b/app/browser/context.tsx index d09b991bf..807ab9614 100644 --- a/app/browser/context.tsx +++ b/app/browser/context.tsx @@ -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", @@ -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 );