From 79d89f93d8ac2670cb4a546e95f90a5ee23e4b06 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 19 Jul 2023 11:13:26 +0200 Subject: [PATCH 1/2] action-list.js: Activate list item depending on detail url - Fix that when we select an list item (comment/downtime...) in the detail view, an Auto or manual container refresh cannot activate the list item again. This happens when multiple action lists exists in detail view and the selected item is not from the first available action list. --- public/js/action-list.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/public/js/action-list.js b/public/js/action-list.js index 41115d074..e0abc35ef 100644 --- a/public/js/action-list.js +++ b/public/js/action-list.js @@ -614,27 +614,21 @@ let _this = event.data.self; let container = event.target; let isTopLevelContainer = container.matches('#main > :scope'); - let detailUrl = _this.icinga.utils.parseUrl( - _this.icinga.history.getCol2State().replace(/^#!/, '') - ); - let list = null; - let toActiveItems = []; if (event.currentTarget !== container || _this.isProcessingRequest) { // Nested containers are not processed multiple times || still processing selection/navigation request return; - } else if (isTopLevelContainer && container.id !== 'col1') { - if (isAutoRefresh) { - return; - } - // only for browser back/forward navigation - list = _this.findDetailUrlActionList(); - } else { - list = container.querySelector('.action-list'); + } else if (isAutoRefresh && isTopLevelContainer && container.id !== 'col1') { + return; } + let list = _this.findDetailUrlActionList(); + if (list && list.matches('[data-icinga-multiselect-url], [data-icinga-detail-url]')) { - let allItems = Array.from(list.querySelectorAll(':scope > [data-action-item]')); + let detailUrl = _this.icinga.utils.parseUrl( + _this.icinga.history.getCol2State().replace(/^#!/, '') + ); + let toActiveItems = []; if (list.dataset.icingaMultiselectUrl === detailUrl.path) { for (const filter of _this.parseSelectionQuery(detailUrl.query.slice(1))) { let item = list.querySelector( @@ -655,6 +649,7 @@ } } + let allItems = Array.from(list.querySelectorAll(':scope > [data-action-item]')); _this.clearSelection(allItems.filter(item => ! toActiveItems.includes(item))); _this.setActive(toActiveItems); From b99bec844d8c96b8baa24d5ec717664659cc8e14 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 19 Jul 2023 11:30:13 +0200 Subject: [PATCH 2/2] action-list.js: Fix console error - The browser cannot differ between auto-completed input and user input, which causes the onKeydown function to be triggered when browser suggestions for an input field are selected. --- public/js/action-list.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/js/action-list.js b/public/js/action-list.js index e0abc35ef..5332ba6de 100644 --- a/public/js/action-list.js +++ b/public/js/action-list.js @@ -182,9 +182,11 @@ let pressedArrowUpKey = event.key === 'ArrowUp'; let focusedElement = document.activeElement; - if (_this.isProcessingLoadMore || ( - event.key.toLowerCase() !== 'a' && ! pressedArrowDownKey && ! pressedArrowUpKey - )) { + if ( + _this.isProcessingLoadMore + || ! event.key // input auto-completion is triggered + || (event.key.toLowerCase() !== 'a' && ! pressedArrowDownKey && ! pressedArrowUpKey) + ) { return; }