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

Tooltips do not work on elements inside Shadow DOM #24918

Closed
ericcarino opened this issue Nov 30, 2017 · 13 comments
Closed

Tooltips do not work on elements inside Shadow DOM #24918

ericcarino opened this issue Nov 30, 2017 · 13 comments
Labels

Comments

@ericcarino
Copy link

ericcarino commented Nov 30, 2017

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

@Johann-S
Copy link
Member

Johann-S commented Nov 30, 2017

That's true as we use jQuery and jQuery access to the DOM, Currently Bootstrap do not handle Shadow DOM.

I made a CodePen with our latest release (beta 2) : https://codepen.io/Johann-S/pen/YERLxV

EDIT :

It's totally doable to fix our JS to allow folk to use Bootstrap in shadow DOM, but it seems our CSS do not work 😟

BTW it's not very well supported see : https://caniuse.com/#feat=shadowdom

/CC @mdo @andresgalante @XhmikosR @bardiharborow

@andresgalante
Copy link
Collaborator

andresgalante commented Nov 30, 2017

The web is going toward Webcomponents, I think it's important to enable users to implement bootstrap with the ShadowDom

@ericcarino
Copy link
Author

@Johann-S What is the CodePen supposed to demonstrate? Were you able to get the tooltip to work? I've tried on Chrome and Safari and I don't see it working.

@Johann-S
Copy link
Member

Nothing but it's better to use the latest release which do not use Tether 😂

@LMOkino
Copy link

LMOkino commented Dec 11, 2017

Will this problem be fixed? If so, when do you think it will be fixed? Our product would like to use this feature if it gets fixed soon.

@Johann-S
Copy link
Member

I made a branch (v4-dev-johann-shadow) which allow Tooltips/Popovers to work on Shadow dom see my commit
if the other core members accept that I'll continue my work

@mdo
Copy link
Member

mdo commented Dec 31, 2017

@Johann-S I'm fine supporting it—seems to make sense that we do.

@LMOkino
Copy link

LMOkino commented Feb 19, 2018

@Johann-S Have your changes been committed yet?

@LMOkino
Copy link

LMOkino commented Apr 2, 2018

@Johann-S Just pinging you to see what the status is of this issue. Please let us know what's going on and when this may be fixed.

@Johann-S
Copy link
Member

Johann-S commented Apr 3, 2018

I'm waiting for an approval of @mdo, @XhmikosR or @bardiharborow on #25150

@gfan95
Copy link

gfan95 commented Aug 22, 2018

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

@pashvin
Copy link

pashvin commented Nov 30, 2018

Is this still waiting for approval?

@Johann-S
Copy link
Member

No I have to do some rework and rebase my branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants