Skip to content

Commit 7c0c853

Browse files
committed
fix: Fix broken FocusManager tree unregistration.
1 parent 4e8bb98 commit 7c0c853

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

core/focus_manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class FocusManager {
148148
if (!this.isRegistered(tree)) {
149149
throw Error(`Attempted to unregister not registered tree: ${tree}.`);
150150
}
151-
const treeIndex = this.registeredTrees.findIndex((tree) => tree === tree);
151+
const treeIndex = this.registeredTrees.findIndex((reg) => reg === tree);
152152
this.registeredTrees.splice(treeIndex, 1);
153153

154154
const focusedNode = FocusableTreeTraverser.findFocusedNode(tree);

tests/mocha/focus_manager_test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,18 @@ suite('FocusManager', function () {
305305

306306
assert.isTrue(isRegistered);
307307
});
308+
309+
test('for unregistered tree with other registered tree returns false', function () {
310+
this.focusManager.registerTree(this.testFocusableTree2);
311+
this.focusManager.registerTree(this.testFocusableTree1);
312+
this.focusManager.unregisterTree(this.testFocusableTree1);
313+
314+
const isRegistered = this.focusManager.isRegistered(
315+
this.testFocusableTree1,
316+
);
317+
318+
assert.isFalse(isRegistered);
319+
});
308320
});
309321

310322
suite('getFocusedTree()', function () {

0 commit comments

Comments
 (0)