fix: dont add comments to full block fields by maribethb · Pull Request #9263 · RaspberryPiFoundation/blockly

@maribethb

The basics

The details

Resolves

Fixes #9260

Proposed Changes

  • Modifies precondition for "add comment" context menu option to hide the option if the block is a simple reporter block with a full-block field. If the block already has a comment, the option is shown so that it can be removed.
  • Also fixed the type of the getFields generator so that next().value would be typed correctly as Field | undefined instead of any

Reason for Changes

You can't interact with the comment icon on full-block fields.

Test Coverage

  1. Drag a math_number block to the advanced playground in geras renderer
  2. Add a comment to it with context menu
  3. Change renderer to zelos
  4. You can remove the comment with context menu
  5. Now you can no longer add a comment with context menu

Documentation

Additional Information

@maribethb

gonfunko

@@ -365,7 +371,11 @@ export function registerComment() {
!block!.isInFlyout &&

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, mind adding a block && condition at the beginning and then dropping the non-null assertions on all the remaining conditions?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, done

@maribethb