From f8b68aee7af8793b694eb7bb74a227739b0f83f0 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 12 Mar 2021 14:14:56 +0100 Subject: [PATCH] Fix back button on mobile devices --- Logic/Actors/SelectedFeatureHandler.ts | 2 -- Logic/Web/Hash.ts | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Logic/Actors/SelectedFeatureHandler.ts b/Logic/Actors/SelectedFeatureHandler.ts index 1b49703..ce36242 100644 --- a/Logic/Actors/SelectedFeatureHandler.ts +++ b/Logic/Actors/SelectedFeatureHandler.ts @@ -18,9 +18,7 @@ export default class SelectedFeatureHandler { this._featureSource = featureSource; const self = this; hash.addCallback(h => { - console.log("Hash is now ", h) if (h === undefined || h === "") { - console.error("Deselecting feature...") selectedFeature.setData(undefined); }else{ self.selectFeature(); diff --git a/Logic/Web/Hash.ts b/Logic/Web/Hash.ts index 6fc18fc..473f3d1 100644 --- a/Logic/Web/Hash.ts +++ b/Logic/Web/Hash.ts @@ -1,6 +1,9 @@ import {UIEventSource} from "../UIEventSource"; import {Utils} from "../../Utils"; +/** + * Wrapper around the hash to create an UIEventSource from it + */ export default class Hash { public static hash: UIEventSource = Hash.Get(); @@ -33,12 +36,14 @@ export default class Hash { return; } + history.pushState({}, "") window.location.hash = "#" + h; }); window.onhashchange = () => { let newValue = window.location.hash.substr(1); + console.log("The hash is now:", newValue) if (newValue === "") { newValue = undefined; }