From b046a3cf144392a5686f3ba8a01308c262ba16d9 Mon Sep 17 00:00:00 2001 From: jahorton Date: Mon, 27 Jun 2022 10:09:11 +0700 Subject: [PATCH 1/2] fix(web): null-guard for refreshLayout --- web/source/osk/oskView.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/source/osk/oskView.ts b/web/source/osk/oskView.ts index abbf6b5d76..67cf9478c0 100644 --- a/web/source/osk/oskView.ts +++ b/web/source/osk/oskView.ts @@ -449,6 +449,12 @@ namespace com.keyman.osk { return; } + // Proper layout cannot occur if the OSKView's dimensions have not yet + // been properly specified in some fashion. + if(!this.width || !this.height) { + return; + } + // Step 1: have the necessary conditions been met? const fixedSize = this.width && this.height && this.width.absolute && this.height.absolute; const computedStyle = getComputedStyle(this._Box); From 70913b915535655d4223d16ebb985661a137a2be Mon Sep 17 00:00:00 2001 From: jahorton Date: Mon, 27 Jun 2022 10:14:21 +0700 Subject: [PATCH 2/2] fix(web): a more polished version --- web/source/osk/oskView.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/web/source/osk/oskView.ts b/web/source/osk/oskView.ts index 67cf9478c0..f1631ddc93 100644 --- a/web/source/osk/oskView.ts +++ b/web/source/osk/oskView.ts @@ -449,14 +449,9 @@ namespace com.keyman.osk { return; } - // Proper layout cannot occur if the OSKView's dimensions have not yet - // been properly specified in some fashion. - if(!this.width || !this.height) { - return; - } - // Step 1: have the necessary conditions been met? - const fixedSize = this.width && this.height && this.width.absolute && this.height.absolute; + const hasDimensions = this.width && this.height; + const fixedSize = hasDimensions && this.width.absolute && this.height.absolute; const computedStyle = getComputedStyle(this._Box); const isInDOM = computedStyle.height != '' && computedStyle.height != 'auto'; @@ -464,7 +459,7 @@ namespace com.keyman.osk { if(fixedSize) { this._computedWidth = this.width.val; this._computedHeight = this.height.val; - } else if(isInDOM) { + } else if(isInDOM && hasDimensions) { const parent = this._Box.offsetParent as HTMLElement; this._computedWidth = this.width.val * (this.width.absolute ? 1 : parent.offsetWidth); this._computedHeight = this.height.val * (this.height.absolute ? 1 : parent.offsetHeight);