From 09cd51ac7109947153d57cc34e2f196a0661bbdb Mon Sep 17 00:00:00 2001 From: Troy Coutu Date: Thu, 3 Oct 2019 12:21:52 -0400 Subject: [PATCH 1/2] fix broken glass button in openlayers 6 --- src/nominatim.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nominatim.js b/src/nominatim.js index 6d47e52..c097c97 100644 --- a/src/nominatim.js +++ b/src/nominatim.js @@ -299,8 +299,10 @@ export class Nominatim { expand() { removeClass(this.els.input, klasses.spin); addClass(this.els.control, klasses.glass.expanded); - window.setTimeout(() => this.els.input.focus(), 100); - this.listenMapClick(); + window.setTimeout(() => { + this.listenMapClick(); + this.els.input.focus(); + }, 100); } collapse() { From 062d07cef2f9f553f332f3005f621bdea5fee20f Mon Sep 17 00:00:00 2001 From: Troy Coutu Date: Thu, 3 Oct 2019 13:23:14 -0400 Subject: [PATCH 2/2] prevent search button and input from triggering click events on map --- src/nominatim.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/nominatim.js b/src/nominatim.js index c097c97..36a104f 100644 --- a/src/nominatim.js +++ b/src/nominatim.js @@ -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(); @@ -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 = ''; @@ -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) { @@ -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() {