Skip to content

fix(blocks): use static tooltip for controls_ifelse block#9897

Open
sheitabrk wants to merge 1 commit into
RaspberryPiFoundation:v13from
sheitabrk:fix/controls-ifelse-static-tooltip
Open

fix(blocks): use static tooltip for controls_ifelse block#9897
sheitabrk wants to merge 1 commit into
RaspberryPiFoundation:v13from
sheitabrk:fix/controls-ifelse-static-tooltip

Conversation

@sheitabrk
Copy link
Copy Markdown

The basics

The details

Resolves

Fixes #9813

Proposed Changes

In packages/blockly/blocks/logic.ts, on the controls_ifelse block definition:

  1. Drop the controls_if_tooltip extension (intended for the mutable controls_if block).
  2. Fix a typo in the static tooltip field: BKYCONTROLS_IF_TOOLTIP_2 becomes BKY_CONTROLS_IF_TOOLTIP_2 (missing underscore after BKY).

Reason for Changes

The controls_if_tooltip extension reads this.elseifCount_ and this.elseCount_, which are populated by controls_if_mutator. The controls_ifelse block has no mutator, so both counts are undefined. The extension always falls into its first branch and returns Msg['CONTROLS_IF_TOOLTIP_1'] ("If a value is true, then do some statements."), which is the tooltip for a simple if block rather than the if/else shape that controls_ifelse actually has.

The block already declared a static tooltip pointing to CONTROLS_IF_TOOLTIP_2 ("If a value is true, then do the first block of statements. Otherwise, do the second block of statements."), which is the correct text. However the message reference was misspelled (BKYCONTROLS_IF_TOOLTIP_2 instead of BKY_CONTROLS_IF_TOOLTIP_2), so it would not have resolved even if the extension was not there to override it.

Removing the extension lets the static tooltip take effect, and fixing the typo makes that static tooltip actually resolve to the right message.

Test Coverage

Verified manually by hovering the controls_ifelse block in the Blockly playground before and after the change. Before: shows the if-only tooltip. After: shows the if/else tooltip as defined in CONTROLS_IF_TOOLTIP_2 in msg/json/en.json.

The change does not touch any code path covered by automated unit tests.

Documentation

No documentation changes needed. The message strings in msg/json/en.json and msg/messages.js are already correct (CONTROLS_IF_TOOLTIP_2 exists with the proper text); the bug was only in how the block referenced them.

Additional Information

The fix was suggested directly by @NeilFraser in #9813.

@sheitabrk sheitabrk requested a review from a team as a code owner May 19, 2026 00:10
@sheitabrk sheitabrk requested a review from gonfunko May 19, 2026 00:10
@github-actions github-actions Bot added the PR: fix Fixes a bug label May 19, 2026
The controls_ifelse block was using the controls_if_tooltip dynamic
extension, which reads this.elseifCount_ and this.elseCount_ set by
the controls_if_mutator. Since controls_ifelse has no mutator, both
counts are undefined and the extension always returned TOOLTIP_1 (for
a simple if), instead of TOOLTIP_2 (for if/else).

The static tooltip already declared on the block was unreachable
because of a typo (BKYCONTROLS_IF_TOOLTIP_2 was missing the underscore
after BKY) and would have been overridden by the extension anyway.

Fix the message key typo and drop the extension so the static
TOOLTIP_2 string is displayed instead.

Fixes RaspberryPiFoundation#9813

Signed-off-by: sheitabrk <44614193+sheitabrk@users.noreply.github.com>
@sheitabrk sheitabrk force-pushed the fix/controls-ifelse-static-tooltip branch from a697a03 to f8d38d7 Compare May 19, 2026 00:11
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Welcome! It looks like this is your first pull request in Blockly, so here are a couple of tips:

  • You can find tips about contributing to Blockly and how to validate your changes on our developer site.
  • We use conventional commits to make versioning the package easier. Make sure your commit message is in the proper format or learn how to fix it.
  • If any of the other checks on this PR fail, you can click on them to learn why. It might be that your change caused a test failure, or that you need to double-check the style guide.
    Thank you for opening this PR! A member of the Blockly team will review it soon.

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