mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-05-20 14:44:51 +02:00
feat(keyboard): add Escape key to close/deselect place card
Pressing Escape when a place is selected now: - Closes the place card - Clears the selected place state - Removes the boundary outline from the map - Clears the selected label highlight Same behavior as clicking empty map area.
This commit is contained in:
parent
a1a499de07
commit
e53ff561e8
1 changed files with 25 additions and 0 deletions
|
|
@ -1864,6 +1864,31 @@ const MapView = forwardRef(function MapView(_, ref) {
|
|||
}
|
||||
}, [selectedPlace])
|
||||
|
||||
// Escape key to close/deselect place card
|
||||
useEffect(() => {
|
||||
if (!selectedPlace) return
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
const map = mapInstance.current
|
||||
const store = useStore.getState()
|
||||
|
||||
// Clear selected place and click marker
|
||||
store.clearSelectedPlace()
|
||||
store.clearClickMarker()
|
||||
|
||||
// Clear boundary
|
||||
if (updateBoundaryRef.current) updateBoundaryRef.current(null)
|
||||
|
||||
// Clear highlight
|
||||
if (map) setSelectedHighlight(map, null)
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown)
|
||||
return () => document.removeEventListener('keydown', handleKeyDown)
|
||||
}, [selectedPlace])
|
||||
|
||||
// Update route polyline when route changes
|
||||
useEffect(() => {
|
||||
const map = mapInstance.current
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue