From a6bafcc063fc5a2990a6725731ae9e976e095362 Mon Sep 17 00:00:00 2001 From: mathuo <6710312+mathuo@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:29:03 +0000 Subject: [PATCH] feat: short-circuit resize calls when display:none --- packages/dockview-core/src/resizable.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/dockview-core/src/resizable.ts b/packages/dockview-core/src/resizable.ts index d06418528..02df77be0 100644 --- a/packages/dockview-core/src/resizable.ts +++ b/packages/dockview-core/src/resizable.ts @@ -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