fix(blocks): use static tooltip for controls_ifelse block#9897
Open
sheitabrk wants to merge 1 commit into
Open
fix(blocks): use static tooltip for controls_ifelse block#9897sheitabrk wants to merge 1 commit into
sheitabrk wants to merge 1 commit into
Conversation
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>
a697a03 to
f8d38d7
Compare
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes #9813
Proposed Changes
In
packages/blockly/blocks/logic.ts, on thecontrols_ifelseblock definition:controls_if_tooltipextension (intended for the mutablecontrols_ifblock).tooltipfield:BKYCONTROLS_IF_TOOLTIP_2becomesBKY_CONTROLS_IF_TOOLTIP_2(missing underscore afterBKY).Reason for Changes
The
controls_if_tooltipextension readsthis.elseifCount_andthis.elseCount_, which are populated bycontrols_if_mutator. Thecontrols_ifelseblock has no mutator, so both counts areundefined. The extension always falls into its first branch and returnsMsg['CONTROLS_IF_TOOLTIP_1']("If a value is true, then do some statements."), which is the tooltip for a simpleifblock rather than theif/elseshape thatcontrols_ifelseactually has.The block already declared a static
tooltippointing toCONTROLS_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_2instead ofBKY_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_ifelseblock in the Blockly playground before and after the change. Before: shows theif-only tooltip. After: shows theif/elsetooltip as defined inCONTROLS_IF_TOOLTIP_2inmsg/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.jsonandmsg/messages.jsare already correct (CONTROLS_IF_TOOLTIP_2exists 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.