From 5f8f391de2d768b949635dfabd87d97701892fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Grabowski?= Date: Thu, 1 Dec 2022 08:16:12 +0100 Subject: [PATCH] IBX-4277: [UDW] Tooltips from left menu aren't visible (#642) --- .../public/js/scripts/core/custom.tooltip.js | 1 + .../public/js/scripts/helpers/tooltips.helper.js | 16 +++++++++++++--- .../components/tab-selector/tab.selector.js | 8 +++++++- .../Behat/Component/UniversalDiscoveryWidget.php | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/bundle/Resources/public/js/scripts/core/custom.tooltip.js b/src/bundle/Resources/public/js/scripts/core/custom.tooltip.js index 641ed06cbc..93473d94d0 100644 --- a/src/bundle/Resources/public/js/scripts/core/custom.tooltip.js +++ b/src/bundle/Resources/public/js/scripts/core/custom.tooltip.js @@ -1,3 +1,4 @@ (function (global, doc, ibexa) { ibexa.helpers.tooltips.parse(); + ibexa.helpers.tooltips.observe(); })(window, window.document, window.ibexa); diff --git a/src/bundle/Resources/public/js/scripts/helpers/tooltips.helper.js b/src/bundle/Resources/public/js/scripts/helpers/tooltips.helper.js index 10921a16d5..b48c3e94fe 100644 --- a/src/bundle/Resources/public/js/scripts/helpers/tooltips.helper.js +++ b/src/bundle/Resources/public/js/scripts/helpers/tooltips.helper.js @@ -13,7 +13,15 @@ const observer = new MutationObserver((mutationsList) => { if (lastInsertTooltipTarget) { mutationsList.forEach((mutation) => { - const { removedNodes } = mutation; + const { addedNodes, removedNodes } = mutation; + + if (addedNodes.length) { + addedNodes.forEach((addedNode) => { + if (addedNode instanceof Element) { + parse(addedNode); + } + }); + } if (removedNodes.length) { removedNodes.forEach((removedNode) => { @@ -159,11 +167,13 @@ bootstrap.Tooltip.getOrCreateInstance(tooltipNode).hide(); } }; - - observer.observe(doc.querySelector('body'), observerConfig); + const observe = (baseElement = doc) => { + observer.observe(baseElement, observerConfig); + }; ibexa.addConfig('helpers.tooltips', { parse, hideAll, + observe, }); })(window, window.document, window.ibexa, window.bootstrap); diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/components/tab-selector/tab.selector.js b/src/bundle/ui-dev/src/modules/universal-discovery/components/tab-selector/tab.selector.js index 6d64f79a51..701a7a398e 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/components/tab-selector/tab.selector.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/components/tab-selector/tab.selector.js @@ -35,7 +35,13 @@ const TabSelector = () => { }); return ( -
+
); diff --git a/src/lib/Behat/Component/UniversalDiscoveryWidget.php b/src/lib/Behat/Component/UniversalDiscoveryWidget.php index f28f4abc1c..91fd6f99c9 100644 --- a/src/lib/Behat/Component/UniversalDiscoveryWidget.php +++ b/src/lib/Behat/Component/UniversalDiscoveryWidget.php @@ -136,7 +136,7 @@ public function changeTab($tabName): void $this->getHTMLPage()->findAll($this->getLocator('categoryTabSelector')) ->getByCriterion(new ElementAttributeCriterion('data-original-title', $tabName))->click(); $this->getHTMLPage()->findAll($this->getLocator('selectedTab')) - ->getByCriterion(new ElementAttributeCriterion('title', $tabName))->assert()->isVisible(); + ->getByCriterion(new ElementAttributeCriterion('data-bs-original-title', $tabName))->assert()->isVisible(); } public function selectBookmark(string $bookmarkName): void