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:
Matt 2026-04-30 03:41:22 +00:00
commit e53ff561e8

View file

@ -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