From cb0824736b9a95a073c92f7b8d72b03ed9fe44eb Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 30 May 2025 13:09:52 -0700 Subject: [PATCH] fix: Fix bug that caused the focus manager to attempt to focus unfocusable elements. (#9117) --- core/layer_manager.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/layer_manager.ts b/core/layer_manager.ts index 1d5afdd74..fd7d8fe23 100644 --- a/core/layer_manager.ts +++ b/core/layer_manager.ts @@ -104,9 +104,11 @@ export class LayerManager { moveToDragLayer(elem: IRenderedElement & IFocusableNode) { this.dragLayer?.appendChild(elem.getSvgRoot()); - // Since moving the element to the drag layer will cause it to lose focus, - // ensure it regains focus (to ensure proper highlights & sent events). - getFocusManager().focusNode(elem); + if (elem.canBeFocused()) { + // Since moving the element to the drag layer will cause it to lose focus, + // ensure it regains focus (to ensure proper highlights & sent events). + getFocusManager().focusNode(elem); + } } /** @@ -117,9 +119,11 @@ export class LayerManager { moveOffDragLayer(elem: IRenderedElement & IFocusableNode, layerNum: number) { this.append(elem, layerNum); - // Since moving the element off the drag layer will cause it to lose focus, - // ensure it regains focus (to ensure proper highlights & sent events). - getFocusManager().focusNode(elem); + if (elem.canBeFocused()) { + // Since moving the element off the drag layer will cause it to lose focus, + // ensure it regains focus (to ensure proper highlights & sent events). + getFocusManager().focusNode(elem); + } } /**