From b1c908dee93e022bedae044fd6949a5eab9491ac Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Fri, 14 Jun 2024 13:53:51 +0700 Subject: [PATCH] fix(web): prevent desktop OSK crash when addKeyboards is called before engine init Fixes: #11785 Fixes: KEYMAN-WEB-KC --- .../engine/osk/src/views/floatingOskView.ts | 13 +++ web/src/test/manual/web/index.html | 1 + web/src/test/manual/web/issue11785/index.html | 109 ++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 web/src/test/manual/web/issue11785/index.html diff --git a/web/src/engine/osk/src/views/floatingOskView.ts b/web/src/engine/osk/src/views/floatingOskView.ts index 11b26073c4..ec1bc0877a 100644 --- a/web/src/engine/osk/src/views/floatingOskView.ts +++ b/web/src/engine/osk/src/views/floatingOskView.ts @@ -51,6 +51,7 @@ export default class FloatingOSKView extends OSKView { // Add header element to OSK only for desktop browsers this.titleBar = new TitleBar(this.titleDragHandler); + // this.titleBar.on('help', () => { this.legacyEvents.callEvent('helpclick', {}); }); @@ -91,6 +92,12 @@ export default class FloatingOSKView extends OSKView { listenerSpy.on('listenerremoved', onListenedEvent); } + if(this.activeKeyboard) { + // If the keyboard was loaded during OSK init, we may need to set the + // title in place now, as it wasn't possible at the standard time. + this.postKeyboardAdjustments(); + } + this.loadPersistedLayout(); } @@ -119,6 +126,12 @@ export default class FloatingOSKView extends OSKView { } protected postKeyboardAdjustments() { + // It is possible for this to be called during OSK initialization, + // when `this.titleBar` has not yet been initialized. + if(!this.titleBar) { + return; + } + // Add header element to OSK only for desktop browsers this.enableMoveResizeHandlers(); if(this.activeKeyboard) { diff --git a/web/src/test/manual/web/index.html b/web/src/test/manual/web/index.html index 218eaa3a45..8ee99a5ac3 100644 --- a/web/src/test/manual/web/index.html +++ b/web/src/test/manual/web/index.html @@ -75,6 +75,7 @@

Test text selection (#9073)

Test key-cap scaling / font load interactions (#10506)

Test page interaction + engine-initialization race condition handling (#10743)

+

Test OSK loading with early add-keyboard calls (#11785)

Other

Keystroke processing regression test engine.


diff --git a/web/src/test/manual/web/issue11785/index.html b/web/src/test/manual/web/issue11785/index.html new file mode 100644 index 0000000000..bd82343ca9 --- /dev/null +++ b/web/src/test/manual/web/issue11785/index.html @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + KeymanWeb Test Page - Keyboard Quick-Load + + + + + + + + + + + + + + + + + + + + +

KeymanWeb Test Page - Keyboard Quick-Load

+ +
+ +
+ +

Type in your language in this text area:

+ + +

or in this input field:

+ + + +

Add a keyboard by keyboard name:

+ + + +

Add a keyboard by BCP-47 language code:

+ + + +

Add a keyboard by language name(s):

+ + + +

Return to testing home page

+
+ + +
+

--End of Document--

+ + + + +