From 41d14cf84966eb40f9805d05b1e5990c4d177f65 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 30 Jul 2024 16:20:51 +0200 Subject: [PATCH] ActionList: Take items with css propery `display:contents` into account For example, the elements of icingadb/hostgroup are `display:contents`, which leads to scrollIntoView() having no effect. --- asset/js/widget/ActionList.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/asset/js/widget/ActionList.js b/asset/js/widget/ActionList.js index c1033ada..77ce1b8d 100644 --- a/asset/js/widget/ActionList.js +++ b/asset/js/widget/ActionList.js @@ -14,6 +14,14 @@ define(["../notjQuery"], function ($) { this.lastActivatedItemUrl = null; this.lastTimeoutId = null; this.processing = false; + this.isDisplayContents = false; + + let firstItem = this.getDirectionalNext(null, false); + if (firstItem + && (! firstItem.checkVisibility() && firstItem.firstChild && firstItem.firstChild.checkVisibility()) + ) { + this.isDisplayContents = true; + } } bind() { @@ -406,9 +414,13 @@ define(["../notjQuery"], function ($) { * @param isArrowUp Whether the arrow up key is pressed, if not, arrow down key is assumed */ scrollItemIntoView(item, isArrowUp) { - item.scrollIntoView({block: "nearest"}); let directionalNext = this.getDirectionalNext(item, isArrowUp); + if (this.isDisplayContents) { + item = item.firstChild; + directionalNext = directionalNext ? directionalNext.firstChild : null; + } + item.scrollIntoView({block: "nearest"}); if (directionalNext) { directionalNext.scrollIntoView({block: "nearest"}); }