Skip to content

Commit 2fd7ed8

Browse files
Francisca105anees-asghar
authored andcommitted
Refactor zoomToElement logic in VenueStands component and router replace instead of push
1 parent 797356f commit 2fd7ed8

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/app/(authenticated)/venue/VenueStands.tsx

+4-14
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const VenueStands: React.FC<VenueStandsProps> = ({ companies }) => {
106106
const updateSearchParam = (newDay: string) => {
107107
const params = new URLSearchParams(searchParams.toString());
108108
params.set("day", newDay);
109-
router.push(`${pathname}?${params.toString()}`, { scroll: false });
109+
router.replace(`${pathname}?${params.toString()}`, { scroll: false });
110110
};
111111

112112
useEffect(() => {
@@ -142,19 +142,9 @@ const VenueStands: React.FC<VenueStandsProps> = ({ companies }) => {
142142
centerOnInit={true}
143143
>
144144
{({ zoomIn, zoomOut, resetTransform, zoomToElement, ...rest }) => {
145-
useEffect(() => {
146-
setTimeout(() => {
147-
if (companyParam) {
148-
let element = document.getElementById(
149-
`company-${companyParam}`
150-
);
151-
if (element) {
152-
console.log("Zooming to element", element);
153-
zoomToElement(`company-${companyParam}`, 3);
154-
}
155-
}
156-
}, 300); // Wait for the SVG to render
157-
}, [companyParam]);
145+
setTimeout(() => {
146+
zoomToElement(`company-${companyParam}`, 3);
147+
}, 300); // Wait for the SVG to render
158148

159149
return (
160150
<>

0 commit comments

Comments
 (0)