Skip to content

Commit

Permalink
prevent search button and input from triggering click events on map
Browse files Browse the repository at this point in the history
  • Loading branch information
Autre31415 committed Oct 3, 2019
1 parent 09cd51a commit 062d07c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/nominatim.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export class Nominatim {

setListeners() {
let timeout, lastQuery;
const openSearch = () => {
const openSearch = evt => {
evt.stopPropagation();

hasClass(this.els.control, klasses.glass.expanded)
? this.collapse()
: this.expand();
Expand All @@ -77,6 +79,9 @@ export class Nominatim {
this.query(value);
}
};
const stopBubbling = evt => {
evt.stopPropagation();
};
const reset = evt => {
this.els.input.focus();
this.els.input.value = '';
Expand All @@ -102,6 +107,7 @@ export class Nominatim {
}
};
this.els.input.addEventListener('keypress', query, false);
this.els.input.addEventListener('click', stopBubbling, false);
this.els.input.addEventListener('input', handleValue, false);
this.els.reset.addEventListener('click', reset, false);
if (this.options.targetType === TARGET_TYPE.GLASS) {
Expand Down Expand Up @@ -299,10 +305,8 @@ export class Nominatim {
expand() {
removeClass(this.els.input, klasses.spin);
addClass(this.els.control, klasses.glass.expanded);
window.setTimeout(() => {
this.listenMapClick();
this.els.input.focus();
}, 100);
window.setTimeout(() => this.els.input.focus(), 100);
this.listenMapClick();
}

collapse() {
Expand Down

0 comments on commit 062d07c

Please sign in to comment.