fix: remove duplicate ESC handlers causing double history.back()
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>
This commit is contained in:
@@ -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<UpdateCheckResult | null>(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(() => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user