Skip to content

Commit f19b7f1

Browse files
authored
Fix URL hash change (#3746)
* fix onHashChange function of url manager * update changelog
1 parent 5c28ba3 commit f19b7f1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
2020

2121
### Fixed
2222

23+
- Fixed an error that occured when changing the URL hash. [#3746](https://github.com/scalableminds/webknossos/pull/3746)
2324
- The modals for a new task description and recommended task settings are no longer shown in read-only tracings. [#3724](https://github.com/scalableminds/webknossos/pull/3724)
2425
- Fixed a bug where some NMLs caused the webKnossos tab to freeze during NML upload. [#3758](https://github.com/scalableminds/webknossos/pull/3758)
2526

frontend/javascripts/oxalis/controller/url_manager.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ class UrlManager {
4646
window.history.replaceState({}, null, url);
4747
}
4848

49-
onHashChange() {
49+
onHashChange = () => {
5050
const stateString = location.hash.slice(1);
51-
if (stateString) {
51+
if (stateString.includes("=")) {
52+
// The hash was changed by a comment link, for example `activeNode=12`
5253
const [key, value] = stateString.split("=");
5354
// The value can either be a single number or multiple numbers delimited by a ,
54-
applyState({ [key]: value.indexOf(",") > -1 ? value.split(",").map(Number) : Number(value) });
55+
applyState({ [key]: value.includes(",") ? value.split(",").map(Number) : Number(value) });
56+
} else {
57+
// The hash was changed by the user
58+
applyState(this.parseUrl());
5559
}
56-
}
60+
};
5761

5862
parseUrl(): UrlManagerState {
5963
// State string format:

0 commit comments

Comments
 (0)