Skip to content

Commit d081873

Browse files
authored
Merge branch 'main' into nrc-input-arg
2 parents ccb0386 + 0e341d7 commit d081873

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/routes/Settings.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Dialog, Transition } from '@headlessui/react'
22
import { Fragment, useEffect, useRef } from 'react'
3-
import { useHotkeys } from 'react-hotkeys-hook'
43
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'
54

65
import { CustomIcon } from '@src/components/CustomIcon'
@@ -10,23 +9,26 @@ import { KeybindingsSectionsList } from '@src/components/Settings/KeybindingsSec
109
import { SettingsSearchBar } from '@src/components/Settings/SettingsSearchBar'
1110
import { SettingsSectionsList } from '@src/components/Settings/SettingsSectionsList'
1211
import { SettingsTabs } from '@src/components/Settings/SettingsTabs'
13-
import { useDotDotSlash } from '@src/hooks/useDotDotSlash'
1412
import { PATHS } from '@src/lib/paths'
1513
import type { SettingsLevel } from '@src/lib/settings/settingsTypes'
1614

1715
export const Settings = () => {
1816
const navigate = useNavigate()
1917
const [searchParams, setSearchParams] = useSearchParams()
20-
const close = () => navigate(location.pathname.replace(PATHS.SETTINGS, ''))
18+
const close = () => {
19+
// This makes sure input texts are saved before closing the dialog (eg. default project name).
20+
if (document.activeElement instanceof HTMLInputElement) {
21+
document.activeElement.blur()
22+
}
23+
navigate(location.pathname.replace(PATHS.SETTINGS, ''))
24+
}
2125
const location = useLocation()
2226
const isFileSettings = location.pathname.includes(PATHS.FILE)
2327
const searchParamTab =
2428
(searchParams.get('tab') as SettingsLevel | 'keybindings') ??
2529
(isFileSettings ? 'project' : 'user')
2630

2731
const scrollRef = useRef<HTMLDivElement>(null)
28-
const dotDotSlash = useDotDotSlash()
29-
useHotkeys('esc', () => navigate(dotDotSlash()))
3032

3133
// Scroll to the hash on load if it exists
3234
useEffect(() => {

0 commit comments

Comments
 (0)