From be94c2849a8f173bfef82e4e68562fd9b9f7ffcf Mon Sep 17 00:00:00 2001 From: mohanadft Date: Mon, 31 Aug 2026 16:35:09 +0300 Subject: [PATCH] fix(events): clear ?event= param when its modal closes The query param added by the share-link "copy link" button was sticking around in the URL after closing the modal, even though the event was no longer on screen. Strip it via clearEventLinkParam() in both close handlers. --- src/components/Events.tsx | 10 ++++++++-- src/components/events/EventsNew.tsx | 9 ++++++++- src/utils/copyAnchorLink.ts | 10 ++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/components/Events.tsx b/src/components/Events.tsx index 4ca0057..253a748 100644 --- a/src/components/Events.tsx +++ b/src/components/Events.tsx @@ -9,7 +9,7 @@ import { type EventSection, type UpcomingEvent, } from "../utils/eventSections"; -import { copyAnchorLink, copyEventLink } from "../utils/copyAnchorLink"; +import { copyAnchorLink, copyEventLink, clearEventLinkParam } from "../utils/copyAnchorLink"; import { formatSpeakerList, getDescriptionExcerpt, @@ -735,7 +735,13 @@ export default function Events({ )} - setSelectedEvent(null)} /> + { + setSelectedEvent(null); + clearEventLinkParam(); + }} + /> ); } diff --git a/src/components/events/EventsNew.tsx b/src/components/events/EventsNew.tsx index e0f435d..8056254 100644 --- a/src/components/events/EventsNew.tsx +++ b/src/components/events/EventsNew.tsx @@ -1,6 +1,7 @@ import { useEffect, useRef, useState } from "react"; import type { EventItem } from "../../store/eventsClient"; import { groupIntoSections, isEventPast } from "../../utils/eventSections"; +import { clearEventLinkParam } from "../../utils/copyAnchorLink"; import { EventModalContext, useVisitorZoneReady, @@ -119,7 +120,13 @@ export default function EventsNew({ initialEvents = [] }: EventsNewProps) { )} {selectedEvent && ( - setSelectedEvent(null)} /> + { + setSelectedEvent(null); + clearEventLinkParam(); + }} + /> )} diff --git a/src/utils/copyAnchorLink.ts b/src/utils/copyAnchorLink.ts index 50086fb..08867d5 100644 --- a/src/utils/copyAnchorLink.ts +++ b/src/utils/copyAnchorLink.ts @@ -30,3 +30,13 @@ export async function copyEventLink(id: string): Promise { return false; } } + +// Strips a `?event=` param left by copyEventLink (or a pasted deep link) once +// its modal is closed, so the URL doesn't keep pointing at an event that's no +// longer on screen. +export function clearEventLinkParam(): void { + const url = new URL(window.location.href); + if (!url.searchParams.has("event")) return; + url.searchParams.delete("event"); + history.replaceState(null, "", `${url.pathname}${url.search}${url.hash}`); +}