Skip to content

Commit

Permalink
Ignore keypresses when a form is focused. Release new route-snapper-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Oct 23, 2024
1 parent 107891b commit 59159b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion route-snapper-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "route-snapper-ts",
"description": "Draw routes in MapLibre snapped to a street network using client-side routing. TypeScript bindings",
"version": "0.0.7",
"version": "0.0.8",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down
13 changes: 11 additions & 2 deletions route-snapper-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ export class RouteTool {
if (!this.active) {
return;
}

// Ignore keypresses if the user is focused on a form
let tag = (e.target as HTMLElement).tagName;
if (tag == "INPUT" || tag == "TEXTAREA") {
return;
}

if (e.key == "Escape") {
e.stopPropagation();
this.cancel();
Expand All @@ -159,8 +166,10 @@ export class RouteTool {
if (!this.active) {
return;
}
// Ignore keypresses if we're not focused on the map
if ((e.target as HTMLElement).tagName == "INPUT") {

// Ignore keypresses if the user is focused on a form
let tag = (e.target as HTMLElement).tagName;
if (tag == "INPUT" || tag == "TEXTAREA") {
return;
}

Expand Down

0 comments on commit 59159b2

Please sign in to comment.