Merge pull request #458 from mathuo/455-floating-groups-lose-size-if-instance-toggled-with-display-none

feat: short-circuit resize calls when display:none
This commit is contained in:
mathuo 2024-01-18 16:02:30 +00:00 committed by GitHub
commit e5334f0fd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,6 +45,22 @@ export abstract class Resizable extends CompositeDisposable {
return;
}
if (!this._element.offsetParent) {
/**
* offsetParent === null is equivalent to display: none being set on the element or one
* of it's parents. In the display: none case the size will become (0, 0) which we do
* not want to propagate.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
*
* You could use checkVisibility() but at the time of writing it's not supported across
* all Browsers
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
*/
return;
}
if (!isInDocument(this._element)) {
/**
* since the event is dispatched through requestAnimationFrame there is a small chance