Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-71148] avoid empty tooltips #8975

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions war/src/main/js/components/tooltips/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you doing null checks deliberately not with === etc? (Curiosity more than request for change)

) {
tippy(
element,
Object.assign(
{
content: (element) =>
element.getAttribute("tooltip").replace(/<br[ /]?\/?>|\\n/g, "\n"),
content: () => tooltip.replace(/<br[ /]?\/?>|\\n/g, "\n"),
onCreate(instance) {
instance.reference.setAttribute("title", instance.props.content);
},
Expand All @@ -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 =
Expand Down