Repository: jenkinsci/jenkins
File: src/main/js/components/dropdowns/utils.js (JavaScript)

Code before:
            callback(instance);
          };
          if (immediate) {
            onload();
          } else {
            ["mouseenter", "focus"].forEach((event) => {
              instance.reference.addEventListener(event, onload);
            });
          }
        },
        onHide(instance) {
          if (
            instance.props.trigger === "mouseenter" &&
            !instance.clickToHide
          ) {
            const dropdowns = document.querySelectorAll("[data-tippy-root]");
            const isMouseOverAnyDropdown = Array.from(dropdowns).some(
              (dropdown) => dropdown.matches(":hover"),
            );

            return !isMouseOverAnyDropdown;
          }
          instance.clickToHide = false;
        },
      },
      options,
    ),
  );
}

/*
 * Generates the contents for the dropdown
 */
function generateDropdownItems(items, compact) {
  const menuItems = document.createElement("div");
  menuItems.classList.add("jenkins-dropdown");
  if (compact === true) {
    menuItems.classList.add("jenkins-dropdown--compact");
  }

  items
    .map((item) => {
      if (item.type === "CUSTOM") {
        return item.contents;
      }

      if (item.type === "HEADER") {
        return Templates.heading(item.label);
      }

      if (item.type === "SEPARATOR") {

Review comment (suggestion):
we should return true here if I understand correctly so the instance gets hidden.

https://atomiks.github.io/tippyjs/v5/all-props/

>  onHide	noop	Lifecycle hook invoked when the tippy begins to transition out.
> You can cancel hiding by returning false from this lifecycle.

 To harmonize the method signature with return (e.g. `return !isMouseOverAnyDropdown;`), you need to ensure the function returns a value, which should be true to allow hiding unless a specific condition is met.

```suggestion
          instance.clickToHide = false;
          // return true to indicate we want hide, returning false would prevent the instance to be hidden
          return true;
```

Code after:
            });

            callback(instance);
          };
          if (immediate) {
            onload();
          } else {
            ["mouseenter", "focus"].forEach((event) => {
              instance.reference.addEventListener(event, onload);
            });
          }
        },
        onHide(instance) {
          if (
            instance.props.trigger === "mouseenter" &&
            !instance.clickToHide
          ) {
            const dropdowns = document.querySelectorAll("[data-tippy-root]");
            const isMouseOverAnyDropdown = Array.from(dropdowns).some(
              (dropdown) => dropdown.matches(":hover"),
            );

            return !isMouseOverAnyDropdown;
          }

          instance.clickToHide = false;
          return true;
        },
      },
      options,
    ),
  );
}

/*
 * Generates the contents for the dropdown
 */
function generateDropdownItems(items, compact) {
  const menuItems = document.createElement("div");
  menuItems.classList.add("jenkins-dropdown");
  if (compact === true) {
    menuItems.classList.add("jenkins-dropdown--compact");
  }

  items
    .map((item) => {
      if (item.type === "CUSTOM") {
        return item.contents;
      }

      if (item.type === "HEADER") {