/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import React, { useEffect, useRef } from "react"; import { getCityFromTimeZone } from "./ClocksHelpers"; export function EditClocksPanel({ clockZones, canAddClock, onShowAddClock, onEditClock, onRemoveClock, onClose, }) { const backButtonRef = useRef(null); // Focus the back button when the panel opens. Double-rAF so this fires // one frame after closeContextMenu's blur, which is scheduled in the // same event handler when opening from the context menu. useEffect(() => { let outerId = 0; let innerId = 0; outerId = requestAnimationFrame(() => { innerId = requestAnimationFrame(() => { backButtonRef.current?.focus?.(); }); }); return () => { cancelAnimationFrame(outerId); cancelAnimationFrame(innerId); }; }, []); return (
{ if (e.key === "Escape") { onClose(); } }} >

{canAddClock && ( )}
); }