Skip to content

Commit 1e1c4ac

Browse files
authored
feat(web): allow navigating the map with arrow keys (#24080)
1 parent d952b62 commit 1e1c4ac

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

web/src/lib/actions/shortcut.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ export const shortcutLabel = (shortcut: Shortcut) => {
3939
/** Determines whether an event should be ignored. The event will be ignored if:
4040
* - The element dispatching the event is not the same as the element which the event listener is attached to
4141
* - The element dispatching the event is an input field
42+
* - The element dispatching the event is a map canvas
4243
*/
4344
export const shouldIgnoreEvent = (event: KeyboardEvent | ClipboardEvent): boolean => {
4445
if (event.target === event.currentTarget) {
4546
return false;
4647
}
4748
const type = (event.target as HTMLInputElement).type;
48-
return ['textarea', 'text', 'date', 'datetime-local', 'email', 'password'].includes(type);
49+
return (
50+
['textarea', 'text', 'date', 'datetime-local', 'email', 'password'].includes(type) ||
51+
(event.target instanceof HTMLCanvasElement && event.target.classList.contains('maplibregl-canvas'))
52+
);
4953
};
5054

5155
export const matchesShortcut = (event: KeyboardEvent, shortcut: Shortcut) => {

0 commit comments

Comments
 (0)