Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle esc key in settings #4702

Merged
merged 4 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- constrain size of webxdc window by available screen-workarea-space #4683
- fix that in html email view links without schema didn't open in browser #4690
- fix clicking on the same anchor multiple timed disn't work in html email view #4690
- close second level settings form with Escape key #4128

<a id="1_54_1"></a>

Expand Down
13 changes: 13 additions & 0 deletions packages/frontend/src/components/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ export default function Settings({ onClose }: DialogProps) {
const tx = useTranslationFunction()
const [settingsMode, setSettingsMode] = useState<SettingsView>('main')

useEffect(() => {
document.onkeydown = (evt: KeyboardEvent) => {
if (
window.__settingsOpened &&
evt.key === 'Escape' &&
settingsMode !== 'main'
) {
evt.preventDefault()
setSettingsMode('main')
}
}
}, [settingsMode])

useEffect(() => {
if (window.__settingsOpened) {
throw new Error(
Expand Down
Loading