Revert tooltip observer change as it does not work properly. #2890
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #2864
The change introduced by https://github.com/solidusio/solidus/pull/2421/files caused a regression in tooltips where they don't go away when the element is removed from the DOM. It appears the MutationObserver is meant for detecting child elements being removed from the target element, and it does not actually observe the target element itself being removed.
https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
https://developers.google.com/web/updates/2012/02/Detect-DOM-changes-with-Mutation-Observers
https://stackoverflow.com/questions/28598340/mutation-observer-fails-to-detect-elements-dom-removal
So we can either revert the change to using MutationObserver or we would need to change it to observe a different target element, such as, the parent element of our actual target. I gave a go at wrapping the the target with a parent node, and observing the parent node and I couldn't easily get it to work either. So reverting seems easiest solution for now, and I changed from
tooltip.hide()
totooltip.dispose()
to unbind events as well.