refactor context menu and keyboard navigation handling for improved clarity and maintainability

This commit is contained in:
Ross
2025-08-11 10:58:22 +01:00
parent c6f8b271a9
commit de9cf60adc
+7 -2
View File
@@ -1926,6 +1926,8 @@ useEffect(() => {
useEffect(() => {
const el = appRootRef.current;
if (!el) return;
function handleArrowKeyNavigation(e: KeyboardEvent) {
console.log("Handling arrow key navigation", e.key);
console.log("activeViewport", activeViewport);
@@ -1975,8 +1977,11 @@ useEffect(() => {
}
}
window.addEventListener("keydown", handleArrowKeyNavigation);
return () => window.removeEventListener("keydown", handleArrowKeyNavigation);
el.addEventListener("keydown", handleArrowKeyNavigation);
return () => {
el.removeEventListener("keydown", handleArrowKeyNavigation);
};
}, [activeViewport, viewportModes, viewportImageIds, updateOverlay]);