From 17bc96fcd4e53036fd2c59991a30a99b287d363d Mon Sep 17 00:00:00 2001 From: Dan Corin Date: Thu, 3 Jul 2025 13:38:17 -0400 Subject: [PATCH] Add support for escape key to dismiss settings menu (#3225) --- .../src/components/settings/SettingsView.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui/desktop/src/components/settings/SettingsView.tsx b/ui/desktop/src/components/settings/SettingsView.tsx index 7fb63185..3437097d 100644 --- a/ui/desktop/src/components/settings/SettingsView.tsx +++ b/ui/desktop/src/components/settings/SettingsView.tsx @@ -12,6 +12,7 @@ import SchedulerSection from './scheduler/SchedulerSection'; import DictationSection from './dictation/DictationSection'; import { ExtensionConfig } from '../../api'; import MoreMenuLayout from '../more_menu/MoreMenuLayout'; +import { useEffect } from 'react'; export type SettingsViewOptions = { deepLinkConfig?: ExtensionConfig; @@ -28,6 +29,20 @@ export default function SettingsView({ setView: (view: View, viewOptions?: ViewOptions) => void; viewOptions: SettingsViewOptions; }) { + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Escape') { + onClose(); + } + }; + + document.addEventListener('keydown', handleKeyDown); + + return () => { + document.removeEventListener('keydown', handleKeyDown); + }; + }, [onClose]); + return (