From da8e83090aa0923f0f5241ca53acf91c96cb4ae0 Mon Sep 17 00:00:00 2001 From: jahorton Date: Mon, 20 Sep 2021 15:46:59 +0700 Subject: [PATCH] fix(web): touch-based unit test issues --- web/source/osk/browser/keytip.ts | 4 +++- web/source/osk/inputEventCoordinate.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/source/osk/browser/keytip.ts b/web/source/osk/browser/keytip.ts index 47ba68acff..19c62edfe1 100644 --- a/web/source/osk/browser/keytip.ts +++ b/web/source/osk/browser/keytip.ts @@ -31,7 +31,9 @@ namespace com.keyman.osk.browser { let util = keyman.util; // Create and display the preview - if(on) { + // If !key.offsetParent, the OSK is probably hidden. Either way, it's a half- + // decent null-guard check. + if(on && key.offsetParent) { // The key element is positioned relative to its key-square, which is, // in turn, relative to its row. Rows take 100% width, so this is sufficient. // diff --git a/web/source/osk/inputEventCoordinate.ts b/web/source/osk/inputEventCoordinate.ts index 178733e8c0..62de3edde5 100644 --- a/web/source/osk/inputEventCoordinate.ts +++ b/web/source/osk/inputEventCoordinate.ts @@ -50,8 +50,8 @@ namespace com.keyman.osk { } public get activeInputCount(): number { - if(window['TouchEvent'] && this.source instanceof TouchEvent) { - return this.source.touches.length; + if(window['TouchEvent'] && this.source['touches'] !== undefined && this.source['touches'] !== null) { + return this.source['touches'].length; } else { const event = this.source as MouseEvent; return event.buttons > 0 ? 1 : 0;