feat(web): allow navigating the map with arrow keys (#24080)

This commit is contained in:
Lukas
2025-11-21 23:46:30 +01:00
committed by GitHub
parent d952b62053
commit 1e1c4ac9d2

View File

@@ -39,13 +39,17 @@ export const shortcutLabel = (shortcut: Shortcut) => {
/** Determines whether an event should be ignored. The event will be ignored if: /** Determines whether an event should be ignored. The event will be ignored if:
* - The element dispatching the event is not the same as the element which the event listener is attached to * - The element dispatching the event is not the same as the element which the event listener is attached to
* - The element dispatching the event is an input field * - The element dispatching the event is an input field
* - The element dispatching the event is a map canvas
*/ */
export const shouldIgnoreEvent = (event: KeyboardEvent | ClipboardEvent): boolean => { export const shouldIgnoreEvent = (event: KeyboardEvent | ClipboardEvent): boolean => {
if (event.target === event.currentTarget) { if (event.target === event.currentTarget) {
return false; return false;
} }
const type = (event.target as HTMLInputElement).type; const type = (event.target as HTMLInputElement).type;
return ['textarea', 'text', 'date', 'datetime-local', 'email', 'password'].includes(type); return (
['textarea', 'text', 'date', 'datetime-local', 'email', 'password'].includes(type) ||
(event.target instanceof HTMLCanvasElement && event.target.classList.contains('maplibregl-canvas'))
);
}; };
export const matchesShortcut = (event: KeyboardEvent, shortcut: Shortcut) => { export const matchesShortcut = (event: KeyboardEvent, shortcut: Shortcut) => {