From ec4af69e3d53ee331f732ab8607e26339d4a0e50 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 12 May 2025 21:54:19 +0000 Subject: [PATCH 1/2] fix: Improve node interaction robustness. --- core/utils/focusable_tree_traverser.ts | 11 +++++++---- core/workspace_svg.ts | 23 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/core/utils/focusable_tree_traverser.ts b/core/utils/focusable_tree_traverser.ts index 94603edd01b..916437b6a73 100644 --- a/core/utils/focusable_tree_traverser.ts +++ b/core/utils/focusable_tree_traverser.ts @@ -32,13 +32,15 @@ export class FocusableTreeTraverser { * @returns The IFocusableNode currently with focus, or null if none. */ static findFocusedNode(tree: IFocusableTree): IFocusableNode | null { - const root = tree.getRootFocusableNode().getFocusableElement(); + const rootNode = tree.getRootFocusableNode(); + if (!rootNode.canBeFocused()) return null; + const root = rootNode.getFocusableElement(); if ( dom.hasClass(root, FocusableTreeTraverser.ACTIVE_CLASS_NAME) || dom.hasClass(root, FocusableTreeTraverser.PASSIVE_CSS_CLASS_NAME) ) { // The root has focus. - return tree.getRootFocusableNode(); + return rootNode; } const activeEl = root.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR); @@ -99,8 +101,9 @@ export class FocusableTreeTraverser { } // Second, check against the tree's root. - if (element === tree.getRootFocusableNode().getFocusableElement()) { - return tree.getRootFocusableNode(); + const rootNode = tree.getRootFocusableNode(); + if (rootNode.canBeFocused() && element === rootNode.getFocusableElement()) { + return rootNode; } // Third, check if the element has a node. diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 2dae154e05d..bf8390d9f38 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -2728,7 +2728,11 @@ export class WorkspaceSvg if (this.isFlyout && flyout) { for (const flyoutItem of flyout.getContents()) { const elem = flyoutItem.getElement(); - if (isFocusableNode(elem) && elem.getFocusableElement().id === id) { + if ( + isFocusableNode(elem) && + elem.canBeFocused() && + elem.getFocusableElement().id === id + ) { return elem; } } @@ -2742,7 +2746,9 @@ export class WorkspaceSvg const block = this.getBlockById(blockId); if (block) { for (const field of block.getFields()) { - if (field.getFocusableElement().id === id) return field; + if (field.canBeFocused() && field.getFocusableElement().id === id) { + return field; + } } } return null; @@ -2765,6 +2771,7 @@ export class WorkspaceSvg for (const comment of this.getTopComments()) { if ( comment instanceof RenderedWorkspaceComment && + comment.canBeFocused() && comment.getFocusableElement().id === id ) { return comment; @@ -2776,10 +2783,18 @@ export class WorkspaceSvg .map((block) => block.getIcons()) .flat(); for (const icon of icons) { - if (icon.getFocusableElement().id === id) return icon; + if (icon.canBeFocused() && icon.getFocusableElement().id === id) { + return icon; + } if (hasBubble(icon)) { const bubble = icon.getBubble(); - if (bubble && bubble.getFocusableElement().id === id) return bubble; + if ( + bubble && + bubble.canBeFocused() && + bubble.getFocusableElement().id === id + ) { + return bubble; + } } } From 378b35977a3178938086c50070796d2c8811d9d6 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 12 May 2025 22:00:14 +0000 Subject: [PATCH 2/2] chore: Empty commit to re-trigger CI.