web: fix Open button selecting row instead of navigating (#18992)

the `isEventTargetingListener()` function only checked the click target and the immediate parent for interactive elements (like links, buttons and more). when clicking the icon inside the Open button, the DOM structure is:

<a href=...>  <--- 2 levels up, never checked
<pf-tooltip>  <--- immediate parent, not interactive
<i> <---- click target, not interactive

Because <i> and <pf-tooltip> did not match the interactive elements query, the function returned false which caused the table rowClickListener to continue with row selection isntead of allowing the click.

The fix is to update the function to to traverse (up) the entire dom tree from the click target to the listener element (the table cell) and check for each ancestor for the interactive elements.
This commit is contained in:
Dominic R
2025-12-22 09:02:59 -05:00
committed by GitHub
parent 162e05ff9d
commit e3d774b3ef
+12 -4
View File
@@ -22,8 +22,16 @@ export function isEventTargetingListener(event?: Pick<Event, "target" | "current
return false;
}
return !!(
triggerElement.matches(InteractiveElementsQuery) ||
triggerElement.parentElement?.matches(InteractiveElementsQuery)
);
// Traverse up the DOM tree to find any interactive ancestor between
// the trigger element and the listener target (the table cell).
let current: HTMLElement | null = triggerElement;
while (current && current !== listenerTarget) {
if (current.matches(InteractiveElementsQuery)) {
return true;
}
current = current.parentElement;
}
return false;
}