* call blur on current input before closing settings dialogue to save value * separate esc handling is not needed * lint
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import { Dialog, Transition } from '@headlessui/react'
|
||||
import { Fragment, useEffect, useRef } from 'react'
|
||||
import { useHotkeys } from 'react-hotkeys-hook'
|
||||
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import { CustomIcon } from '@src/components/CustomIcon'
|
||||
@ -10,14 +9,19 @@ import { KeybindingsSectionsList } from '@src/components/Settings/KeybindingsSec
|
||||
import { SettingsSearchBar } from '@src/components/Settings/SettingsSearchBar'
|
||||
import { SettingsSectionsList } from '@src/components/Settings/SettingsSectionsList'
|
||||
import { SettingsTabs } from '@src/components/Settings/SettingsTabs'
|
||||
import { useDotDotSlash } from '@src/hooks/useDotDotSlash'
|
||||
import { PATHS } from '@src/lib/paths'
|
||||
import type { SettingsLevel } from '@src/lib/settings/settingsTypes'
|
||||
|
||||
export const Settings = () => {
|
||||
const navigate = useNavigate()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const close = () => navigate(location.pathname.replace(PATHS.SETTINGS, ''))
|
||||
const close = () => {
|
||||
// This makes sure input texts are saved before closing the dialog (eg. default project name).
|
||||
if (document.activeElement instanceof HTMLInputElement) {
|
||||
document.activeElement.blur()
|
||||
}
|
||||
navigate(location.pathname.replace(PATHS.SETTINGS, ''))
|
||||
}
|
||||
const location = useLocation()
|
||||
const isFileSettings = location.pathname.includes(PATHS.FILE)
|
||||
const searchParamTab =
|
||||
@ -25,8 +29,6 @@ export const Settings = () => {
|
||||
(isFileSettings ? 'project' : 'user')
|
||||
|
||||
const scrollRef = useRef<HTMLDivElement>(null)
|
||||
const dotDotSlash = useDotDotSlash()
|
||||
useHotkeys('esc', () => navigate(dotDotSlash()))
|
||||
|
||||
// Scroll to the hash on load if it exists
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user