primereact icon indicating copy to clipboard operation
primereact copied to clipboard

Using the tooltip attribute inside the Shadow Dom crashes Primereact on hover

Open rogiermulders opened this issue 3 years ago • 6 comments

Describe the bug

Probably a niche this bug, but so far everything Primereact works fine for me in the Shadow Dom.

Using the Tooltip component like so <Tooltip target=".custom-target-icon" /> does not work in the Shadow Dom and

<Button label="My Button" tooltip="My Tooltip"/> crashes Primereact like so:

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. which is a typical shadow dom error.

I did NOT include CSS in CodeSandbox. Is handled in the build process and that would mean a lot of work for me to get the CSS working in shadow dom in CodeSandbox

PS primereact Dialog works fine in the shadow dom (attachTo={shadowRoot})

Reproducer

https://4fxj97.csb.app/ https://codesandbox.io/s/4fxj97

PrimeReact version

9.2.0

React version

18.x

Language

ES6

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

Hover over the button to crahs Primereact

Expected behavior

Get the tooltip 'My Tooltip'

rogiermulders avatar Mar 09 '23 09:03 rogiermulders

@mertsincan here is another Shadow DOM one is this the same issue? https://github.com/primefaces/primereact/issues/4096

melloware avatar Mar 09 '23 11:03 melloware

Its not fixed, or well .. it does not crash anymore but it is rendered outside the ShadowDom

I updated CodeSandbox.

rogiermulders avatar Mar 17 '23 18:03 rogiermulders

Thanks a lot for the update! For this case, you can use appendTo property of Tooltip.

mertsincan avatar Mar 17 '23 18:03 mertsincan

I use appendTo property in my example. https://codesandbox.io/s/4fxj97 No style from within the shadow dom as you can see and attach a tooltip with a classname does not work at all.

Here exactly the same example but in the normal DOM https://codesandbox.io/s/y271pj Everything works as expected.

rogiermulders avatar Mar 20 '23 20:03 rogiermulders

@mertsincan thank you for support. can you add a sample of Tooltip with appendTo property in shadow dom?

kevinbuger avatar Nov 06 '23 12:11 kevinbuger

@kevinbuger looks like there are two new open Shadow DOM issues: https://github.com/primefaces/primereact/issues/5246

https://github.com/primefaces/primereact/issues/5240

I would subscribe to these.

melloware avatar Nov 06 '23 12:11 melloware