Skip to content

feat: Add relevant things to full-block field labels#10037

Open
mikeharv wants to merge 4 commits into
RaspberryPiFoundation:mainfrom
mikeharv:full-block-fields
Open

feat: Add relevant things to full-block field labels#10037
mikeharv wants to merge 4 commits into
RaspberryPiFoundation:mainfrom
mikeharv:full-block-fields

Conversation

@mikeharv

@mikeharv mikeharv commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes #9864

Proposed Changes

This updates how ARIA labels are computed for field classes that support full-block fields (FieldInput and FieldDropdown). When recomputeAriaContext() is called for these fields, we were update the aria-label using the full block's label, which includes a lot of additional information. This requires re-inserting the expected field label (with type name) to the right place with the block label.

Examples:

Focusing full-block field, number top block
image
Focusing full-block field, child
image
Information shortcut, shadow
image
Focusing full-block field, dropdown top block
image
Information shortcut
image
Focusing full-block field
image
Information shortcut, disabled
image
Extended Information shortcut
image

Labels are also refreshed automatically when block context changes: BlockSvg delegates aria recomputation to the full-block field on connect/disconnect (setParent) and after drag ends (setDragging(false)), with tests for those paths.

Reason for Changes

Blocks that are full-block field blocks get special cased in block aria composer, but the special case didn't include adding things like "begin stack", "disabled", the custom input name, etc if they are relevant to the block.

Test Coverage

Tests were added that check expected labels for focused blocks similar to those screenshotted above.

@mikeharv mikeharv requested a review from a team as a code owner June 18, 2026 20:33
@mikeharv mikeharv requested a review from maribethb June 18, 2026 20:33
@github-actions github-actions Bot added the PR: feature Adds a feature label Jun 18, 2026
// Full block fields get a more detailed label that includes the block's label
label = computeAriaLabel(this.getSourceBlock() as BlockSvg).replace(
this.computeAriaLabel(false),
label,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This admittedly feels a bit janky, but it's needed because getInputLabels will use includeTypeInfo = false for standard verbosity.

this.getSourceBlock() as BlockSvg,
);

// Insert "Edit" after "Begin stack" if found, otherwise at start.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is vibes based, but it felt odd to read/hear "Edit Begin stack, number:10..."

@microbit-robert

Copy link
Copy Markdown
Collaborator

I've done some initial testing with these changes in MakeCode. When I refresh the page, I see a lot of full block numbers as block inputs that get the "begin stack" prefix when I think they shouldn't. If I delete the block, then hit undo, the "begin stack" prefix is removed and the input name is added. I'm not sure if there's a timing issue here - perhaps the full block field labels are calculated on load before they are attached to block they are in?

Screen.Recording.2026-06-19.at.13.35.14.mov

@microbit-robert

Copy link
Copy Markdown
Collaborator

This is a really daft example, but it's more likely to happen in MakeCode where we have full block text inputs. If the value of the input matches the input name, then weird things happen to the output. The order of elements is switched and repeated? I don't really know what's happening here.

Screen.Recording.2026-06-19.at.17.20.17.mov

@microbit-robert

Copy link
Copy Markdown
Collaborator

Is it worth adding input names to fields as well? Nice to know what P0 and P1 relate to when I focus them for this block for example?

Screenshot 2026-06-22 at 13 05 01

@microbit-robert

microbit-robert commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

I ran into another text mangling example and it does seem to depend on the value of the input. I was able to reproduce in the Blockly playground running locally. Some kind of replacement problem maybe? I haven't investigated.

Update: Ahh it's this code. For this example it amounts to "value 1, a".replace("a", "number: a") - it replaces the first "a" in "value".

I've raised #10050 separately.

Screen.Recording.2026-06-22.at.16.34.55.mov

@mikeharv

Copy link
Copy Markdown
Contributor Author

Hi @microbit-robert. Thanks for the thorough testing here! I've updated this branch with fixes that should remove the timing problems and text mangling. Please feel free to take another look!

@mikeharv mikeharv marked this pull request as ready for review June 22, 2026 18:31
@github-actions github-actions Bot added PR: feature Adds a feature and removed PR: feature Adds a feature labels Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: feature Adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add "begin stack" label and other relevant things to full-block field labels

3 participants