From f0496e8ca5cc2d950aa39d71dd0cdfc38db419b9 Mon Sep 17 00:00:00 2001 From: Daniel Volz Date: Wed, 25 Feb 2026 23:47:52 +0100 Subject: [PATCH] fix: remove duplicate ESC handlers causing double history.back() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AboutModal, ProfileModal, and ShareDialog each had their own useEscapeKey hook AND were handled by the global ESC handler in App.tsx. When ESC was pressed, both fired synchronously, calling history.back() twice — navigating past the current page instead of just closing the modal. Removed the per-modal useEscapeKey calls since the global handler in App.tsx already manages ESC priority for all modals. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- frontend/src/components/AboutModal.tsx | 3 +-- frontend/src/components/ProfileModal.tsx | 3 +-- frontend/src/components/ShareDialog.tsx | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/AboutModal.tsx b/frontend/src/components/AboutModal.tsx index 28c4cb4..d295943 100644 --- a/frontend/src/components/AboutModal.tsx +++ b/frontend/src/components/AboutModal.tsx @@ -1,7 +1,6 @@ import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { FRONTEND_VERSION, GITHUB_URL } from "../App"; -import { useEscapeKey } from "../hooks/useEscapeKey"; interface UpdateCheckResult { status: "up-to-date" | "update-available" | "error"; @@ -18,7 +17,7 @@ export default function AboutModal({ isOpen, onClose }: AboutModalProps) { const [isChecking, setIsChecking] = useState(false); const [updateCheckResult, setUpdateCheckResult] = useState(null); - useEscapeKey(isOpen, onClose); + // ESC is handled by the global handler in App.tsx to avoid double history.back() // Reset check result when modal opens so stale results are never shown useEffect(() => { diff --git a/frontend/src/components/ProfileModal.tsx b/frontend/src/components/ProfileModal.tsx index b0decc2..e793d93 100644 --- a/frontend/src/components/ProfileModal.tsx +++ b/frontend/src/components/ProfileModal.tsx @@ -1,4 +1,3 @@ -import { useEscapeKey } from "../hooks/useEscapeKey"; import { UserProfile } from "./Auth"; interface ProfileModalProps { @@ -7,7 +6,7 @@ interface ProfileModalProps { } export default function ProfileModal({ isOpen, onClose }: ProfileModalProps) { - useEscapeKey(isOpen, onClose); + // ESC is handled by the global handler in App.tsx to avoid double history.back() if (!isOpen) return null; diff --git a/frontend/src/components/ShareDialog.tsx b/frontend/src/components/ShareDialog.tsx index 85371f3..e0b90ec 100644 --- a/frontend/src/components/ShareDialog.tsx +++ b/frontend/src/components/ShareDialog.tsx @@ -5,7 +5,6 @@ import { Check, Copy, Link2, X } from "lucide-react"; import { useTranslation } from "react-i18next"; -import { useEscapeKey } from "../hooks/useEscapeKey"; export interface ShareDialogProps { show: boolean; @@ -44,7 +43,7 @@ export function ShareDialog({ const closeLabel = t("common.close"); const copyLabel = shareCopied ? t("share.copied") : t("share.copyLink"); - useEscapeKey(show, onClose); + // ESC is handled by the global handler in App.tsx to avoid double history.back() if (!show) return null;