From 848c059d5175ac43fb0d6d685f6d022128505b77 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Wed, 5 Jul 2023 16:44:02 -0400 Subject: [PATCH] don't steal focus when removing focused tree items; #1428 --- docs/pages/resources/changelog.md | 1 + src/components/tree/tree.ts | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/docs/pages/resources/changelog.md b/docs/pages/resources/changelog.md index df0c4b84..854ec54e 100644 --- a/docs/pages/resources/changelog.md +++ b/docs/pages/resources/changelog.md @@ -18,6 +18,7 @@ New versions of Shoelace are released as-needed and generally occur when a criti - Fixed a bug in `` where the `background` attribute was never passed to the QR code [#1416] - Fixed a bug in `` where aria attributes were incorrectly applied to the default `` causing Lighthouse errors [#1417] - Fixed a bug in `` that caused navigation to work incorrectly in some case [#1420] +- Fixed a bug in `` that caused focus to be stolen when removing focused tree items [#1428] ## 2.5.2 diff --git a/src/components/tree/tree.ts b/src/components/tree/tree.ts index 3c615611..9889f530 100644 --- a/src/components/tree/tree.ts +++ b/src/components/tree/tree.ts @@ -159,14 +159,8 @@ export default class SlTree extends ShoelaceElement { private handleTreeChanged = (mutations: MutationRecord[]) => { for (const mutation of mutations) { const addedNodes: SlTreeItem[] = [...mutation.addedNodes].filter(SlTreeItem.isTreeItem) as SlTreeItem[]; - const removedNodes = [...mutation.removedNodes].filter(SlTreeItem.isTreeItem) as SlTreeItem[]; addedNodes.forEach(this.initTreeItem); - - // If the focused item has been removed form the DOM, move the focus to the first focusable item - if (removedNodes.includes(this.lastFocusedItem)) { - this.focusItem(this.getFocusableItems()[0]); - } } };