Skip to content

fix: improve fallback behavior for custom input labels#9942

Merged
maribethb merged 6 commits into
RaspberryPiFoundation:v13from
maribethb:input-labels
May 28, 2026
Merged

fix: improve fallback behavior for custom input labels#9942
maribethb merged 6 commits into
RaspberryPiFoundation:v13from
maribethb:input-labels

Conversation

@maribethb
Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes issue with fallback labels for custom inputs appearing for statement inputs that already have a better label.
Also fixes an issue with blocks that contain field images generated from the block factory not setting their alt text appropriately.

Proposed Changes

  • Refactors the label methods for inputs to make it easier to understand when custom labels will be used
  • Only use the fallback "input 1" for statement inputs if there's no other text used in the label
  • Updates the FieldImage constructor to handle the style generated by the block factory (discovered this problem while generating test blocks to use)
  • Adds additional tests

Reason for Changes

trying to improve the makecode if block situation

Test Coverage

Documentation

Additional Information

@maribethb maribethb requested a review from gonfunko May 27, 2026 17:39
@maribethb maribethb requested a review from a team as a code owner May 27, 2026 17:39
@github-actions github-actions Bot added the PR: fix Fixes a bug label May 27, 2026
Comment on lines +393 to +394
typeof value === 'object' &&
value !== null &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably invert these two checks?

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.

that seems fine too, but just curious why?

Copy link
Copy Markdown
Contributor Author

@maribethb maribethb May 27, 2026

Choose a reason for hiding this comment

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

normally value is going to be a string, so having this check first will fail the fastest (desired behavior for the common case) though i'm not sure it really matters either way

break;
case 'field_image':
// Result: new Blockly.FieldImage('http://...', 80, 60, '*')
// Result: new Blockly.FieldImage('http://...', 80, 60, {alt: '*', flipRtl: false})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this also be fixed to use the correct format moving forward? No worries if you're planning to do that in another PR or just file a bug for it

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 the legacy block factory which we'll delete soon so not going to fix it here but can file a bug to fix it in samples

@maribethb maribethb merged commit 695e071 into RaspberryPiFoundation:v13 May 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants