Fix Dialog
cleanup when the Dialog
becomes hidden
#2303
Merged
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.
This PR fixes an issue with the
Dialog
component where it doesn't properly closes and therefore doesn't properly cleans up the scroll locking, focus trapping, ...We already had the
IntersectionObserver
in place for this. But this didn't always trigger properly. For example if theDialog
itself didn't have a proper size, but it's content did.We could update the
root
of the intersection observer to a different element but it becomes hard to know which element to use exactly. Just using theparentElement
of the Dialog seemed enough, but performing some tests broke other components.Instead, let's use a
ResizeObserver
(see browser support: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver#browser_compatibility) which gets properly trigger when a Dialog becomes hidden and when it becomes visible again.