feat: Improve settings navigation hotkey behavior
- Add location check to prevent navigating to settings when already on settings page - Enable hotkey on content editable and form elements - Use useLocation to track current route
This commit is contained in:
parent
b2ebbc1e30
commit
79c7c3dc1c
@ -1,14 +1,19 @@
|
|||||||
import { useHotkeys } from 'react-hotkeys-hook'
|
import { useHotkeys } from 'react-hotkeys-hook'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useLocation, useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
const NavigationHandler: React.FC = () => {
|
const NavigationHandler: React.FC = () => {
|
||||||
|
const location = useLocation()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
useHotkeys(
|
useHotkeys(
|
||||||
'meta+, ! ctrl+,',
|
'meta+, ! ctrl+,',
|
||||||
function () {
|
function () {
|
||||||
|
if (location.pathname.startsWith('/settings')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
navigate('/settings/provider')
|
navigate('/settings/provider')
|
||||||
},
|
},
|
||||||
{ splitKey: '!' }
|
{ splitKey: '!', enableOnContentEditable: true, enableOnFormTags: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user