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

[Bug] Tooltips Do Not Work With ShadowDOMs #48

Open
DonIsaac opened this issue Jan 22, 2020 · 7 comments
Open

[Bug] Tooltips Do Not Work With ShadowDOMs #48

DonIsaac opened this issue Jan 22, 2020 · 7 comments
Labels

Comments

@DonIsaac
Copy link

Heyo,

My preact application uses a shadow dom as a mounting point, and tooltips are not appearing. I did some digging through the source code, and I believe I know why.

// ReactHint#toggleEvents, line 30
;(click || hasEvents) && document[action]('click', this.toggleHint)
;(focus || hasEvents) && document[action]('focusin', this.toggleHint)
;(hover || hasEvents) && document[action]('mouseover', this.toggleHint)
;(click || hover || hasEvents) && document[action]('touchend', this.toggleHint)

Events in the shadow dom are not propagated up to document, so toggleHint never fires.

One way that this could be fixed is by allowing users to specify the element where the ReactHint singleton should listen for events

@slmgc slmgc added the bug label Jan 23, 2020
@slmgc
Copy link
Owner

slmgc commented Jan 23, 2020

Thanks for reporting this! I'll try to fix this

@slmgc
Copy link
Owner

slmgc commented Jan 24, 2020

@DonIsaac could you also provide a simple repro?

@DonIsaac
Copy link
Author

I can't use the codebase that I'm using as an example, but if I get time I'll upload a simple repro

@emilschutte
Copy link

A related issue is that tooltips don't work in a React portal in another browser window (due to this hard binding to the main window's document).

@slmgc
Copy link
Owner

slmgc commented Jul 17, 2020

@emilschutte hm, thanks for letting me know, could you provide a repro so I could try fixing that?

@emilschutte
Copy link

emilschutte commented Jul 17, 2020

Let's see, not sure I remember exactly 😅 ... I think it was something like this:

https://codesandbox.io/s/react-fiddle-l7qdj?file=/src/App.js

@evgenyfadeev
Copy link

A related issue is that tooltips don't work in a React portal in another browser window (due to this hard binding to the main window's document).

I made it to work in the portal by adding a separate instance of in the root of the portal, however, the tooltips open in all instances of the and sometimes you can see more than one tooltips at the same time.

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

4 participants