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
Can't use within iframe #121
Comments
Looks like I had a typo that caused a nesting of Tippy's in a way I hadn't intended. |
Means an invalid |
Found the issue in tippy core:
So somehow the button node within the frame's context is not an instanceof To make it work we need a different technique (weird how this issue has never come up before. I'm guessing it happens only when the tippy script is in a different document, since CodePen/Sandbox work fine in the frames) This fixes it: function isElement(value) {
return isType(value, 'Element');
}
function isNodeList(value) {
return isType(value, 'NodeList');
}
function isType(value, type) {
const str = {}.toString.call(value);
return str.indexOf('[object') === 0 && str.indexOf(`${type}]`) > -1;
} That said this also opens up a host of other issues surrounding tippy's hardcoded use of |
Run: npm i @tippy.js/react@latest iframes should be supported now |
Awesome! 🎉 Got temporarily pulled onto a different project, but I'll try to check it out sometime this week. Thanks @atomiks! |
I'm using React Frame component to wrap my entire app in an iframe as I'm building a widget.
I'm getting the following errors when I try to use Tippy
index.js:159 Uncaught TypeError: instance.set is not a function
index.js:148 Uncaught TypeError: instance.destroy is not a function
index.js:1437 The above error occurred in the <Tippy> component: in Tippy (created by ForwardRef(TippyWrapper)) in ForwardRef(TippyWrapper) (at ItemDetail/index.js:84)…
I assumed the issue was that Tippy was trying to inject itself to the document body instead of the iframe's document body, so I used React Frame's context consumer and passed its document to my component and added it to
appendTo
.I tried console.logging the
instance
in theonCreate
prop and it just returned an empty array, so that'd explain why there's no methods oninstance
Digging into Tippy's code, it appears the creation of the Tippy div is hardcoded to the main document
Is there something I'm missing to allow usage within an iframe? Or am I correct that
ssrSafeCreateDiv
would need to be refactored to allow passing in a different document?The text was updated successfully, but these errors were encountered: