diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5412fdd2..fad2bc12 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,10 @@
- Result tab progress bars grow smoothly and are shown even when only one corpus is selected
- Removed old test code
+### Fixed
+
+- Error when loading a non-`visible_modes` mode [#426](https://github.com/spraakbanken/korp-frontend/issues/426)
+
## [9.8.1] - 2025-01-23
### Fixed
diff --git a/app/scripts/components/app-header.ts b/app/scripts/components/app-header.ts
index 9b09b812..fbc38cb8 100644
--- a/app/scripts/components/app-header.ts
+++ b/app/scripts/components/app-header.ts
@@ -40,7 +40,7 @@ angular.module("korpApp").component("appHeader", {
-
- {{mode.label | locObj:lang}}
+ {{mode.label | locObj:$oot.lang}}
@@ -235,17 +235,18 @@ angular.module("korpApp").component("appHeader", {
$ctrl.modes = _.filter(settings["modes"], (item) => !item.labOnly)
}
+ // Split modes into visible and menu
$ctrl.visible = $ctrl.modes.slice(0, N_VISIBLE)
+ $ctrl.menu = $ctrl.modes.slice(N_VISIBLE)
+
+ // If current mode is in menu, promote it to visible
+ const modesInMenu = _.remove($ctrl.menu, (item) => item.mode == currentMode)
+ $ctrl.visible.push(...modesInMenu)
$rootScope.$watch("lang", () => {
$scope.lang = $rootScope.lang
- $ctrl.menu = collatorSort($ctrl.modes.slice(N_VISIBLE), "label", $rootScope.lang)
-
- const i = _.map($ctrl.menu, "mode").indexOf(currentMode)
- if (i !== -1) {
- $ctrl.visible.push($ctrl.menu[i])
- $ctrl.menu.splice(i, 1)
- }
+ // Re-sort menu but not visible options
+ $ctrl.menu = collatorSort($ctrl.menu, "label", $rootScope.lang)
})
$ctrl.getUrl = function (modeId) {