-
Notifications
You must be signed in to change notification settings - Fork 529
Conversation
src/createTippy.ts
Outdated
function actualContains(parent: Element, child: Element): boolean { | ||
let target = child; | ||
while(target) { | ||
if (parent.contains(target)) { | ||
return true; | ||
} | ||
target = (child.getRootNode() as any)?.host; | ||
} | ||
return false; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this into dom-utils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Linting/Type checking is failing as |
I checked the latest release, this fix doesn't appear to be in there. |
@hedgehog90 yes, tippy does not release yet since then. |
I'd be very much interested in a new release of tippy that includes this fix as well. I'm currently working on adding tooltip and context menu support to elements that are rendered in a shadow DOM. Tippy has been awesome for this, but right now I'm not able to get click events on context menu items without a few additional workarounds. |
For such a structure where content is a shadow dom:
If we click on innerElement, the
popperContainer.contains(innerElement)
will return false since it is inside a shadow root. But in tippy's logic, we need to treat popperContainer containing innerElement as true.So here comes
actualContains
function which check through the shadow dom to maintain the correct logic.Without this fix, interactive option will not work for dom structure above, see: