fix: Fix broken FocusManager tree unregistration.

This commit is contained in:
Ben Henning
2025-04-22 00:49:52 +00:00
parent 4e8bb9850f
commit 7c0c8536e6
2 changed files with 13 additions and 1 deletions

View File

@@ -148,7 +148,7 @@ export class FocusManager {
if (!this.isRegistered(tree)) {
throw Error(`Attempted to unregister not registered tree: ${tree}.`);
}
const treeIndex = this.registeredTrees.findIndex((tree) => tree === tree);
const treeIndex = this.registeredTrees.findIndex((reg) => reg === tree);
this.registeredTrees.splice(treeIndex, 1);
const focusedNode = FocusableTreeTraverser.findFocusedNode(tree);

View File

@@ -305,6 +305,18 @@ suite('FocusManager', function () {
assert.isTrue(isRegistered);
});
test('for unregistered tree with other registered tree returns false', function () {
this.focusManager.registerTree(this.testFocusableTree2);
this.focusManager.registerTree(this.testFocusableTree1);
this.focusManager.unregisterTree(this.testFocusableTree1);
const isRegistered = this.focusManager.isRegistered(
this.testFocusableTree1,
);
assert.isFalse(isRegistered);
});
});
suite('getFocusedTree()', function () {