From fce06269e1f67edd01525019d61b8e5fe2328096 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 28 Feb 2023 10:59:53 +0100 Subject: [PATCH] Bug 32728: Fix warning There is a couple of wrong things from the previous patch: * There is a warning in the console Firefox [Vue Router warn]: Unexpected error when starting the router: TypeError: document.getElementById(...) is null Chrome [Vue Router warn]: Unexpected error when starting the router: TypeError: Cannot read properties of null (reading 'click') That's because the tabs are not initialized yet, and so the tab is not correctly selected when the app is loaded. * "Search titles" is selected when on packages, and "Search packages" is selected when on titles This patch remove the warning and fix the second problem. However the tab is still wrong when the app is loaded. Will see later if that can be fixed, but it's not trivial at first glance. Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 87e717406bdbd48340115fe7522a7184359116bb) Signed-off-by: Matt Blenkinsop --- koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts index c03753f130..e4290931df 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts @@ -63,10 +63,13 @@ router.beforeEach((to, from) => { }); router.afterEach((to, from) => { let tab_id = 1; // Agreements - if ( to.path.match(/\/erm\/eholdings\/local\/titles/)){ + if (to.path.match(/\/erm\/eholdings\/local\/packages/)) { tab_id = 2; - } else if ( to.path.match(/\/erm\/eholdings\/local\/packages/)){ + } else if (to.path.match(/\/erm\/eholdings\/local\/titles/)) { tab_id = 3; } - document.getElementById('ui-id-' + tab_id).click(); -}) + let node = document.getElementById("ui-id-" + tab_id); + if (node) { + node.click(); + } +}); -- 2.20.1