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.

<img width="266" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5635476/ef4c5b39-fe61-44f8-8e10-580247b378b2">
This commit is contained in:
Bogdan Chadkin authored and GitHub committed 2024-05-25 22:26:29 +03:00
1 parent c621ce90ca
commit bf251b5f85
1 file changed
+5 -1
@@ -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() ?? {}
);