Skip to content

Commit

Permalink
action-list: Take items with css propery display:contents into account
Browse files Browse the repository at this point in the history
The list items of icingadb/(hostgroups/servicegroups) have the css property `display:contents`, which leads to the scrollIntoView() function having no effect.
  • Loading branch information
sukhwinder33445 committed Jul 30, 2024
1 parent 8afbb73 commit 1dc2090
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion public/js/action-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,15 @@
* @param pressedKey Pressed key (`ArrowUp` or `ArrowDown`)
*/
scrollItemIntoView(item, pressedKey) {
item.scrollIntoView({block: "nearest"});
let directionalNext = this.getDirectionalNext(item, pressedKey);

if (item.parentElement.hasAttribute('data-is-display-contents')) {
item = item.firstChild;
directionalNext = directionalNext ? directionalNext.firstChild : null;
}

item.scrollIntoView({block: "nearest"});

if (directionalNext) {
directionalNext.scrollIntoView({block: "nearest"});
}
Expand Down Expand Up @@ -737,6 +743,30 @@
list = _this.findDetailUrlActionList(container);
}

if (! list || ! list.hasAttribute('data-is-display-contents')) {
// no detail view || not checked before
let actionLists = null;
if (! list) {
actionLists = document.querySelectorAll('.action-list');
} else {
actionLists = [list];
}

for (let actionList of actionLists) {
let firstSelectableItem = actionList.querySelector(':scope > [data-action-item]');
if (
firstSelectableItem
&& (
! firstSelectableItem.checkVisibility()
&& firstSelectableItem.firstChild
&& firstSelectableItem.firstChild.checkVisibility()
)
) {
actionList.dataset.isDisplayContents = "";
}
}
}

if (list && list.matches('[data-icinga-multiselect-url], [data-icinga-detail-url]')) {
let detailUrl = _this.icinga.utils.parseUrl(
_this.icinga.history.getCol2State().replace(/^#!/, '')
Expand Down

0 comments on commit 1dc2090

Please sign in to comment.