Merge pull request #4983 from keymanapp/cherrypick/web/4961-banner-init

fix(web): Make banner initialization more robust 🍒
This commit is contained in:
Marc Durdin 2021-04-26 20:21:30 +10:00 committed by GitHub
commit c8f779b08c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();
}
}
}
}
/**