Skip to content

Commit 0675943

Browse files
authored
[JENKINS-71148] avoid empty tooltips (#8975)
* [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. * better null checks
1 parent 6460778 commit 0675943

File tree

1 file changed

+8
-6
lines changed
  • war/src/main/js/components/tooltips

1 file changed

+8
-6
lines changed

war/src/main/js/components/tooltips/index.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@ function registerTooltip(element) {
1919
element._tippy.destroy();
2020
}
2121

22+
const tooltip = element.getAttribute("tooltip");
23+
const htmlTooltip = element.getAttribute("data-html-tooltip");
2224
if (
23-
element.hasAttribute("tooltip") &&
24-
!element.hasAttribute("data-html-tooltip")
25+
tooltip !== null &&
26+
tooltip.trim().length > 0 &&
27+
(htmlTooltip === null || htmlTooltip.trim().length == 0)
2528
) {
2629
tippy(
2730
element,
2831
Object.assign(
2932
{
30-
content: (element) =>
31-
element.getAttribute("tooltip").replace(/<br[ /]?\/?>|\\n/g, "\n"),
33+
content: () => tooltip.replace(/<br[ /]?\/?>|\\n/g, "\n"),
3234
onCreate(instance) {
3335
instance.reference.setAttribute("title", instance.props.content);
3436
},
@@ -44,12 +46,12 @@ function registerTooltip(element) {
4446
);
4547
}
4648

47-
if (element.hasAttribute("data-html-tooltip")) {
49+
if (htmlTooltip !== null && htmlTooltip.trim().length > 0) {
4850
tippy(
4951
element,
5052
Object.assign(
5153
{
52-
content: (element) => element.getAttribute("data-html-tooltip"),
54+
content: () => htmlTooltip,
5355
allowHTML: true,
5456
onCreate(instance) {
5557
instance.props.interactive =

0 commit comments

Comments
 (0)