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

Remove tooltip from DOM on hide #391

Open
evanb2 opened this issue Jan 10, 2020 · 3 comments
Open

Remove tooltip from DOM on hide #391

evanb2 opened this issue Jan 10, 2020 · 3 comments
Labels

Comments

@evanb2
Copy link

evanb2 commented Jan 10, 2020

Instead of setting visibility: hidden, why not remove the element from the DOM?

Is there a way to implement this behavior using the component's API?

@maxfierke
Copy link
Collaborator

@evanb2 this is how the hide behavior works in tooltip.js, the library we use underneath.

In theory, removing the element from the DOM could be done instead, but would incur the cost of removing popper.js/tooltip.js teardown and then removing the DOM node, and then the setup cost again were it to be triggered. If tooltips are triggered by hover (as they often are) this is repeating a whole bunch of work any time someone moves their mouse over a triggering element. In the general case, keeping the DOM node around is better. FWIW, the DOM node is lazily rendered initially by default.

There's no exposed way right now to implement a more aggressive DOM removal, however. You are, however, able to use the isShown property within the component (via the component's block argument) to conditionally render content, but your mileage may vary with regards to how the tooltip reacts to those content changes (might be fine)

@zeppelin
Copy link

zeppelin commented Nov 2, 2020

@maxfierke Our use case is related to rendering the tooltip inside a custom popperContainer. When used in tables where each cell has a tooltip and the table can scroll horizontally inside its container (which is why the container must have overflow: hidden making @popperContainer="body" required, otherwise some of the tooltips would've been cropped), after hovering a sizable number of cells, the horizontal scroll behavior gets slow, because the all tooltips' inline styles (translate) are updated to position each tooltip correctly - unnecessarily, because the tooltip itself is invisible, but it does result in DOM updates nonetheless. So the default behavior is fine for most cases, yet it would be great if there was an option to actually remove the element after the fade out transition is complete.

@msucorey
Copy link

Similar issues here. Because the tooltip stays in the DOM without display:none, having issues where a table resizes after one of the td's shownOn hover tooltips comes in.

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