Skip to content

fix: remove tooltip rendered element from DOM when is not showing #932

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

Merged
merged 7 commits into from
Feb 9, 2023

Conversation

danielbarion
Copy link
Member

@danielbarion danielbarion commented Feb 1, 2023

  • fix the tooltip first show when the element is not rendered (the position was miscalculated)
  • stay with the same behaviors in this PR as before

closes #918

Sorry, something went wrong.

@danielbarion
Copy link
Member Author

Test snapshots not updated yet

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@gabrieljablonski
Copy link
Member

Tests will need to be fixed, since they assumed the tooltip was always in the DOM.

After that, this should be good to merge.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@danielbarion danielbarion marked this pull request as ready for review February 8, 2023 13:07

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@danielbarion danielbarion marked this pull request as draft February 8, 2023 14:23
@gabrieljablonski gabrieljablonski marked this pull request as ready for review February 9, 2023 14:16
Copy link
Member

@gabrieljablonski gabrieljablonski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are simple enough that we probably should be fine for now without them.

@danielbarion danielbarion merged commit f979a60 into master Feb 9, 2023
@danielbarion danielbarion deleted the feat/tooltip-rendered-element-dom branch February 9, 2023 14:21
oshi97 added a commit to yext/studio that referenced this pull request Jul 20, 2023
This PR updates the preview to be passed into an iframe via react portal.
This makes things like fixed styling work as expected within the iframe.

I also added an e.preventDefault() which will prevent previewed pinks from being navigable.
This is preferable over turning off pointer-events completely so that styling still appears as expected.

react-tooltip does not work out of the box inside an iframe, so we have to manually tell it the correct
coordinates to render at. It's also impossible for an iframe to render overflow content, so to render
the tooltip over the preview like we do in one of our screenshots, I shifted the contents of the iframe down
by 50px to make extra space for the tooltip.
https://github.com/yext/studio-prototype/blob/e5318a3f941543db21d101bb474e29fe675a166f/e2e-tests/__screenshots__/error-component-preview.spec.ts/components-with-parsing-errors-2.png
In order to do this I had to update react-tooltip to get access to new props.
However, in 5.7.5 react-tooltip made it so that when the tooltip is not open, it is no longer rendered to the DOM,
as opposed to having visibility hidden. This broke our unit tests so I had to update those.
ReactTooltip/react-tooltip#932

J=SLAP-2821
TEST=manual

I can click on a component within the preview (which is now in an iframe) and the active component will be updated
component highlighting still works as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Tooltips aren't completely hidden on page when not showing
2 participants