Skip to content

Commit

Permalink
Merge pull request #9718 from keymanapp/fix/web/integrated-test-stabi…
Browse files Browse the repository at this point in the history
…lity

fix(web): enhances integrated test stability
  • Loading branch information
jahorton authored Oct 20, 2023
2 parents c287644 + defbd53 commit 374b1fa
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions web/src/app/browser/src/contextManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,17 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat

public deactivateCurrentTarget() {
const priorTarget = this.activeTarget || this.lastActiveTarget;
if(priorTarget) {

/* During integrated tests, it was possible in the past for a `beforeAll`
* -initialized KMW to reach this state between tests. The target fixture
* got cleared, but the `mostRecentTarget` / `lastActiveTarget` was not
* - just the `currentTarget` / `activeTarget`. See #9718.
*
* Newly-added code in `forgetActiveTarget` seeks to prevent this scenario,
* but as there's no consistent repro to prove it sufficient, an appropriate
* guard-condition has been added here too.
*/
if(priorTarget && this.page.isAttached(priorTarget.getElement())) {
this._BlurKeyboardSettings(priorTarget.getElement());
}

Expand All @@ -198,12 +208,19 @@ export default class ContextManager extends ContextManagerBase<BrowserConfigurat
this.focusAssistant.maintainingFocus = false;
this.focusAssistant.restoringFocus = false;

const priorTarget = this.activeTarget || this.lastActiveTarget;
const priorTarget = this.activeTarget || this.mostRecentTarget;
if(priorTarget) {
this._BlurKeyboardSettings(priorTarget.getElement());
}

// Will ensure that the element is no longer active. Does not erase
// it from being the `lastActiveTarget`, though.
this.setActiveTarget(null, true);

// So we erase it here.
if(priorTarget == this.lastActiveTarget) {
this.mostRecentTarget = null;
}
}

public setActiveTarget(target: OutputTarget<any>, sendEvents: boolean) {
Expand Down

0 comments on commit 374b1fa

Please sign in to comment.