From b8716a21a7c46623d27ae28052e8a1f7fc02eda0 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 26 Apr 2021 15:23:57 +0700 Subject: [PATCH] fix(web): Make banner initialization more robust --- web/source/osk/bannerManager.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web/source/osk/bannerManager.ts b/web/source/osk/bannerManager.ts index 8a9d3bb43a..2ba3c7b95c 100644 --- a/web/source/osk/bannerManager.ts +++ b/web/source/osk/bannerManager.ts @@ -143,6 +143,8 @@ namespace com.keyman.osk { this.alwaysShow = optionSpec[key]; break; case 'mayPredict': + // If this toggles our internal flag, it will generate events + // that reconfigures the banner (and internal engine state) appropriately. keyman.core.languageProcessor.mayPredict = optionSpec[key] break; case 'mayCorrect': @@ -156,9 +158,12 @@ namespace com.keyman.osk { // Invalid option specified! } this._options[key] = optionSpec[key]; - } - this.selectBanner(); + // If no banner instance exists yet, go with a safe, blank initialization. + if(!this.activeBanner) { + this.selectBanner('inactive'); + } + } } /** @@ -208,9 +213,7 @@ namespace com.keyman.osk { * allowing logic to automatically hot-swap `Banner`s as needed. * @param state */ - private selectBanner(state?: text.prediction.StateChangeEnum) { - let keyman = com.keyman.singleton; - + private selectBanner(state: text.prediction.StateChangeEnum) { // Only display a SuggestionBanner when LanguageProcessor states it is active.s if(state == 'active') { this.setBanner('suggestion'); @@ -226,7 +229,7 @@ namespace com.keyman.osk { // Triggers the initially-displayed suggestions.s suggestionBanner.postConfigure(); } - } + } } /**