Skip to content
Merged
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
16 changes: 13 additions & 3 deletions apps/insights/src/components/PriceComponentDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ import dynamic from "next/dynamic";
import { useRouter } from "next/navigation";
import { useQueryState, parseAsString } from "nuqs";
import type { ReactNode } from "react";
import { Suspense, useState, useCallback, useMemo, useTransition } from "react";
import {
Suspense,
useState,
useCallback,
useMemo,
useTransition,
useRef,
} from "react";
import {
RouterProvider,
useDateFormatter,
Expand Down Expand Up @@ -68,6 +75,7 @@ export const usePriceComponentDrawer = ({
const drawer = useDrawer();
const router = useRouter();
const [isRouting, startTransition] = useTransition();
const didRestoreUrl = useRef(false);

const navigate = useCallback(
(route: string) => {
Expand Down Expand Up @@ -102,10 +110,12 @@ export const usePriceComponentDrawer = ({
}, [updateSelectedComponentId]);

useMountEffect(() => {
if (selectedComponentId) {
if (selectedComponentId && !didRestoreUrl.current) {
didRestoreUrl.current = true;
const component = components.find(
(component) =>
component[identifiesPublisher ? "publisherKey" : "feedKey"],
component[identifiesPublisher ? "publisherKey" : "feedKey"] ===
selectedComponentId,
);
if (component) {
openDrawer(component);
Expand Down
Loading