From bf251b5f85d2ce13601eb60287934a3cc76bfd28 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sat, 25 May 2024 22:26:29 +0300 Subject: [PATCH] fix: prevent showing not matching history (#3420) We show all history at the moment even when path is changed. Here improved logic to exclude all paths from history not matching current page path pattern. image --- apps/builder/app/builder/features/address-bar.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/builder/app/builder/features/address-bar.tsx b/apps/builder/app/builder/features/address-bar.tsx index e33113e2ec5f..6c1f71528089 100644 --- a/apps/builder/app/builder/features/address-bar.tsx +++ b/apps/builder/app/builder/features/address-bar.tsx @@ -4,6 +4,7 @@ import { mergeRefs } from "@react-aria/utils"; import { forwardRef, useEffect, + useMemo, useRef, useState, type ComponentProps, @@ -273,7 +274,10 @@ const AddressBar = forwardRef< >(({ onSubmit }, ref) => { const publishedOrigin = useStore($publishedOrigin); const path = useStore($selectedPagePath); - const history = useStore($selectedPageHistory); + let history = useStore($selectedPageHistory); + history = useMemo(() => { + return history.filter((item) => matchPathnamePattern(path, item)); + }, [history, path]); const [pathParams, setPathParams] = useState( () => $selectedPagePathParams.get() ?? {} );