question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tooltips do not work on elements inside Shadow DOM

See original GitHub issue

I’m trying to add a tooltip to a button that resides inside a shadow DOM. Unfortunately, does not work. I traced the problem down to this snippet of code inside bootstrap.js.

Tooltip.prototype.show = function show() {
      var _this22 = this;

      if ($(this.element).css('display') === 'none') {
        throw new Error('Please use show on visible elements');
      }

      var showEvent = $.Event(this.constructor.Event.SHOW);
      if (this.isWithContent() && this._isEnabled) {
        if (this._isTransitioning) {
          throw new Error('Tooltip is transitioning');
        }
        $(this.element).trigger(showEvent);

        var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);

        if (showEvent.isDefaultPrevented() || !isInTheDom) {
          return;
        }

isInTheDom is false because jquery.contains doesn’t find the element, which I assume is because it resides inside the shadow DOM. If I manually set this value to true, the tooltip works perfectly. See my screenshot below.

Example

To access my JSBin example, use the link below. http://jsbin.com/qukeye/2/edit?html,js,output

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gfan95commented, Aug 22, 2018

Hi @Johann-S, any updates on this? How long do approvals usually take?

0reactions
Johann-Scommented, Nov 30, 2018

No I have to do some rework and rebase my branch

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make JS tooltips work in Shadow DOM? - Stack Overflow
js https://popper.js.org/) are not working within the Shadow DOM at all. I have also tried to invoke tooltips directly with Popper.js and Tippy....
Read more >
Issue 234100 in chromium: Tooltips in Shadow DOM don't work
1) tooltip of host element is displayed 2) if another tooltip is shown, the tooltip for ShadowDOM is displayed on the previous tooltip....
Read more >
Tooltips · Bootstrap v5.0
Triggering tooltips on hidden elements will not work. Tooltips for .disabled or ... Tooltips can be triggered thanks to an element inside a...
Read more >
Vue Tooltips - examples & tutorial. Bootstrap & Material Design
Triggering tooltips on hidden elements will not work. Tooltips for .disabled or ... Tooltips can be triggered thanks to an element inside a...
Read more >
Bootstrap 5 Tooltips - AdminKit
Tooltips must be hidden before their corresponding elements have been removed from the DOM. Tooltips can be triggered thanks to an element inside...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found