From cdb4824d9d782fa2873bc08bd86aa71e20807717 Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Tue, 20 Feb 2024 22:21:10 +0100 Subject: [PATCH 1/2] [JENKINS71148] avoid empty tooltips when the tooltip or html tooltip is empty or whitespace only it is avoided that the tippy is invoked at all which would otherwise just display a small but empty element. --- war/src/main/js/components/tooltips/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/war/src/main/js/components/tooltips/index.js b/war/src/main/js/components/tooltips/index.js index 6b28e3e7f52b..5e36e857087b 100644 --- a/war/src/main/js/components/tooltips/index.js +++ b/war/src/main/js/components/tooltips/index.js @@ -19,16 +19,18 @@ function registerTooltip(element) { element._tippy.destroy(); } + const tooltip = element.getAttribute("tooltip"); + const htmlTooltip = element.getAttribute("data-html-tooltip"); if ( - element.hasAttribute("tooltip") && - !element.hasAttribute("data-html-tooltip") + tooltip != null && + tooltip.length > 0 && + (htmlTooltip == null || htmlTooltip.length == 0) ) { tippy( element, Object.assign( { - content: (element) => - element.getAttribute("tooltip").replace(/|\\n/g, "\n"), + content: () => tooltip.replace(/|\\n/g, "\n"), onCreate(instance) { instance.reference.setAttribute("title", instance.props.content); }, @@ -44,12 +46,12 @@ function registerTooltip(element) { ); } - if (element.hasAttribute("data-html-tooltip")) { + if (htmlTooltip != null && htmlTooltip.length > 0) { tippy( element, Object.assign( { - content: (element) => element.getAttribute("data-html-tooltip"), + content: () => htmlTooltip, allowHTML: true, onCreate(instance) { instance.props.interactive = From f02c181ccb4e06062c7a83f70d0e25bc7c9c4053 Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Tue, 20 Feb 2024 23:25:25 +0100 Subject: [PATCH 2/2] better null checks --- war/src/main/js/components/tooltips/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/war/src/main/js/components/tooltips/index.js b/war/src/main/js/components/tooltips/index.js index 5e36e857087b..eb74340f2180 100644 --- a/war/src/main/js/components/tooltips/index.js +++ b/war/src/main/js/components/tooltips/index.js @@ -22,9 +22,9 @@ function registerTooltip(element) { const tooltip = element.getAttribute("tooltip"); const htmlTooltip = element.getAttribute("data-html-tooltip"); if ( - tooltip != null && - tooltip.length > 0 && - (htmlTooltip == null || htmlTooltip.length == 0) + tooltip !== null && + tooltip.trim().length > 0 && + (htmlTooltip === null || htmlTooltip.trim().length == 0) ) { tippy( element, @@ -46,7 +46,7 @@ function registerTooltip(element) { ); } - if (htmlTooltip != null && htmlTooltip.length > 0) { + if (htmlTooltip !== null && htmlTooltip.trim().length > 0) { tippy( element, Object.assign(