Skip to content

Commit

Permalink
fix(web): adds newly-needed null guards due to new pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
jahorton committed Apr 8, 2024
1 parent eebf3e5 commit 786c480
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion web/src/app/browser/src/keymanEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,
// Scrolls the document-body to ensure that a focused element remains visible after the OSK appears.
this.contextManager.on('targetchange', (target: OutputTarget<any>) => {
const e = target?.getElement();
(this.osk.activationModel as TwoStateActivator<HTMLElement>).activationTrigger = e;
if(this.osk) {
(this.osk.activationModel as TwoStateActivator<HTMLElement>).activationTrigger = e;
}

if(this.config.hostDevice.touchable) {
if(!e || !target || !this.osk) {
Expand Down
11 changes: 10 additions & 1 deletion web/src/engine/osk/src/views/floatingOskView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class FloatingOSKView extends OSKView {
dfltX: string;
dfltY: string;

layoutSerializer = new FloatingOSKCookieSerializer();
private layoutSerializer = new FloatingOSKCookieSerializer();

private titleBar: TitleBar;
private resizeBar: ResizeBar;
Expand Down Expand Up @@ -220,6 +220,15 @@ export default class FloatingOSKView extends OSKView {
* @return {boolean}
*/
private loadPersistedLayout(): void {
/*
If a keyboard is available during OSK construction, it is possible
for this field to be `undefined`. `loadPersistedLayout` will be called
later in construction, so it's safe to skip.
*/
if(!this.layoutSerializer) {
return;
}

let c = this.layoutSerializer.loadWithDefaults({
visible: 1,
userSet: 0,
Expand Down

0 comments on commit 786c480

Please sign in to comment.