feat: make comment editor separately focusable from comment itself by maribethb · Pull Request #9154 · RaspberryPiFoundation/blockly

The basics

The details

Resolves

Fixes #9121

Proposed Changes

  • Makes the textarea of the workspace comment separately editable from the comment as a whole.
  • Accomplishes this by adding a new class that implements IFocusableNode, CommentEditor
  • This should still be compatible with subclasses of RenderedWorkspaceComment

Screenshot 2025-06-18 at 4 57 52 PM

Reason for Changes

FocusManager does not currently support the scenario where some node is focused, but the thing with browser focus is not the exact element that it thinks should have focus (i.e. the one returned from getFocusableElement). Therefore, it is impossible to have the comment editor textarea separately focusable from the comment as a whole unless there is a separate IFocusableNode object.

These changes not only fix the bug, but they'll allow us to make keyboard navigation possible for workspace comments. Theoretically all we need to do is add a navigation policy that can navigate from the comment as a whole to the text input, similar to how you can navigate to a text input field on a block. So a user could move, delete, or copy a workspace comment when the whole comment is focused, and edit the text when just the editor part is focused.

Test Coverage

Will add tests for workspace comments during this sprint after webdriver tests are working again.

Documentation

The workspace comments documentation focuses on the css class available, so I don't think anything changes there.

Additional Information