Skip to content

Commit

Permalink
Merge pull request #9786 from keymanapp/fix/web/keymanweb.com-cookiel…
Browse files Browse the repository at this point in the history
…ess-default-kbd

fix(web): fixes touch form-factor default kbd on cookieless keymanweb.com page load
  • Loading branch information
jahorton authored Oct 18, 2023
2 parents 536fc7e + 1adc9ea commit 8c3099b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions web/src/app/browser/src/keymanEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,19 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,

await super.init(totalOptions);

// Used by keymanweb.com; if no keyboard-cookie exists, we need this to trigger
// default-stub selection on mobile devices so that a keyboard - and thus, the
// globe key - are accessible.
//
// The `super` call above initializes `keyboardRequisitioner`, as needed here.
this.keyboardRequisitioner.cloudQueryEngine.once('unboundregister', () => {
if(!this.contextManager.activeKeyboard?.keyboard) {
// Autoselects this.keyboardRequisitioner.cache.defaultStub, which will be
// set to an actual keyboard on mobile devices.
this.setActiveKeyboard('', '');
}
});

this.contextManager.initialize(); // will seek to attach to the page, which requires document.body

// Capture the saved-keyboard string now, before we load any keyboards/stubs
Expand Down Expand Up @@ -213,6 +226,8 @@ export default class KeymanEngine extends KeymanEngineBase<BrowserConfiguration,
// If we tracked cloud requests and awaited a Promise.all on pending queries,
// we could handle that too.
this.contextManager.restoreSavedKeyboard(savedKeyboardStr);

await Promise.resolve();
}

get register(): (x: CloudQueryResult) => void {
Expand Down

0 comments on commit 8c3099b

Please sign in to comment.