From de36c49d1ff2bf7858c8cc8762c4c7b9d05c9cb3 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 5 Jun 2018 12:23:59 +0100 Subject: Fix pointer event issue selecting pin on map. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a mobile device that implements pointer events, there are two events that can happen on an /around page – touching the map starts a new report (or goes back to the map if already on a report page); touching a pin pulls in that report’s page. The map touch, which uses an OpenLayers.Handler.Click, operates on click, whereas the pin touch, which uses an OpenLayers.Handler.Feature, operates on touchstart. Neither event cancels the other, which means you can end up either starting a new report, and then it tries to pull in an undefined pin ID report and errors, or the pin report loads and then you instantly go back to the map page. In order to work around this, we disable the map click control when the feature control event starts, and reactivate once the report data has been loaded. --- CHANGELOG.md | 2 ++ web/cobrands/fixmystreet/fixmystreet.js | 3 +++ web/js/map-OpenLayers.js | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fff0c21a5..9681fbb8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Releases * Unreleased + - Bugfixes: + - Fix pointer event issue selecting pin on map. #2130 * v2.3.2 (31st May 2018) - Front end improvements: diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 33bd5e812..1b0063f48 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -1145,6 +1145,9 @@ fixmystreet.display = { fixmystreet.maps.markers_resize(); // force a redraw so the selected marker gets bigger } + // We disabled this upon first touch to prevent it taking effect, re-enable now + fixmystreet.maps.click_control.activate(); + if (typeof callback === 'function') { callback(); } diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 2e62336ed..868e2333e 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -311,6 +311,9 @@ $.extend(fixmystreet.utils, { return; } + // clickFeature operates on touchstart, we do not want the map click taking place on touchend! + fixmystreet.maps.click_control.deactivate(); + // All of this, just so that ctrl/cmd-click on a pin works?! var event; if (typeof window.MouseEvent === 'function') { @@ -720,7 +723,7 @@ $.extend(fixmystreet.utils, { } if (document.getElementById('mapForm')) { - var click = new OpenLayers.Control.Click(); + var click = fixmystreet.maps.click_control = new OpenLayers.Control.Click(); fixmystreet.map.addControl(click); click.activate(); } -- cgit v1.2.3 From e7351414c26b903e938fed67c2ede56f250734a9 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 5 Jun 2018 16:43:33 +0100 Subject: Remove unneeded base in main navigation. This can cause issues with e.g. multi-language sites, and was only needed for cases where the admin was proxied, which we do not suggest any more. --- CHANGELOG.md | 1 + templates/web/base/main_nav.html | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9681fbb8c..8e9a7f0d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Unreleased - Bugfixes: - Fix pointer event issue selecting pin on map. #2130 + - Fix admin navigation links in multi-language installs. * v2.3.2 (31st May 2018) - Front end improvements: diff --git a/templates/web/base/main_nav.html b/templates/web/base/main_nav.html index 9736697e3..189630902 100644 --- a/templates/web/base/main_nav.html +++ b/templates/web/base/main_nav.html @@ -1,7 +1,4 @@ [% - SET base = ""; - SET base = c.cobrand.base_url IF admin; - # DEFAULT would make sense here, except it treats the empty string as falsy # and some cobrands want to set ul_class to an empty string. SET ul_class="nav-menu nav-menu--main" UNLESS ul_class.defined; @@ -11,7 +8,7 @@ [%~ IF c.req.uri.path == uri AND NOT always_url ~%] [% label %] [%~ ELSE ~%] - [% label %] + [% label %] [%~ END ~%] [%~ END %] -- cgit v1.2.3