From e3d17becbdff79eca83a19e6d1559c64ccfffb9e Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Mon, 7 Jul 2025 15:28:54 -0700 Subject: [PATCH] fix: Improve workspace comment keyboard navigation behavior. (#9211) * fix: Prevent tabbing into workspace comments. * fix: Focus workspace comments when navigating to them using the keyboard. --- core/comments/comment_editor.ts | 1 + core/keyboard_nav/line_cursor.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/core/comments/comment_editor.ts b/core/comments/comment_editor.ts index 9a1907e91..69dadd884 100644 --- a/core/comments/comment_editor.ts +++ b/core/comments/comment_editor.ts @@ -52,6 +52,7 @@ export class CommentEditor implements IFocusableNode { dom.HTML_NS, 'textarea', ) as HTMLTextAreaElement; + this.textArea.setAttribute('tabindex', '-1'); dom.addClass(this.textArea, 'blocklyCommentText'); dom.addClass(this.textArea, 'blocklyTextarea'); dom.addClass(this.textArea, 'blocklyText'); diff --git a/core/keyboard_nav/line_cursor.ts b/core/keyboard_nav/line_cursor.ts index aeb80cff1..a301c3b37 100644 --- a/core/keyboard_nav/line_cursor.ts +++ b/core/keyboard_nav/line_cursor.ts @@ -401,6 +401,8 @@ export class LineCursor extends Marker { block.workspace.scrollBoundsIntoView( block.getBoundingRectangleWithoutChildren(), ); + } else if (newNode instanceof RenderedWorkspaceComment) { + newNode.workspace.scrollBoundsIntoView(newNode.getBoundingRectangle()); } }