mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-25 07:17:41 +00:00
Merge pull request #16788 from keymanapp/fix/web/16787_predictionContext
fix(web): don't crash on gestures when banner disabled Fixes: #16787 Fixes: KEYMAN-WEB-YC Fixes: KEYMAN-WEB-SV
This commit is contained in:
commit
27a1046e34
1 changed files with 11 additions and 5 deletions
|
|
@ -577,8 +577,10 @@ export class SuggestionBanner extends Banner {
|
|||
return;
|
||||
}
|
||||
|
||||
const autoselection = this._predictionContext.selected;
|
||||
this._predictionContext.selected = null;
|
||||
const autoselection = this.predictionContext?.selected;
|
||||
if (this.predictionContext) {
|
||||
this.predictionContext.selected = null;
|
||||
}
|
||||
// Always clear pre-existing selections when a new banner input/gesture starts.
|
||||
this.options.forEach((entry) => {
|
||||
entry.highlight(false);
|
||||
|
|
@ -628,9 +630,13 @@ export class SuggestionBanner extends Banner {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.predictionContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The suggestions are still current? Then restore the original
|
||||
// auto-correct suggestion and its highlighting.
|
||||
this._predictionContext.selected = autoselection;
|
||||
this.predictionContext.selected = autoselection;
|
||||
if(autoselection) {
|
||||
for(const entry of this.options) {
|
||||
if(entry.suggestion == autoselection) {
|
||||
|
|
@ -668,11 +674,11 @@ export class SuggestionBanner extends Banner {
|
|||
// Invalidate the suggestions internally, but don't visually update;
|
||||
// this will avoid banner-flicker.
|
||||
this.currentSuggestions = [];
|
||||
this.predictionContext.accept(suggestion.suggestion);
|
||||
this.predictionContext?.accept(suggestion.suggestion);
|
||||
// Trigger new predictions, as no input exists to trigger new ones otherwise.
|
||||
// Reversions will re-use old suggestions, though.
|
||||
if(suggestion.suggestion.tag != 'revert') {
|
||||
this.predictionContext.triggerPredictions();
|
||||
this.predictionContext?.triggerPredictions();
|
||||
}
|
||||
|
||||
// Reset the scroll state
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue