fix: Ensure FieldImage is clickable when appropriate
#9063
Merged
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 part of RaspberryPiFoundation/blockly-keyboard-experimentation#525
Proposed Changes
This introduces an
isClickableoverride forFieldImagethat only allows images to be clickable when they have a click handler.Reason for Changes
Without this change it's possible to navigate to non-clickable images (like the quotes in certain text blocks) since #9054. This is both a confusing experience and causing a test failure in the keyboard navigation plugin: RaspberryPiFoundation/blockly-keyboard-experimentation#527 (comment).
Test Coverage
New tests have been added for
FieldImage.isClickable()and have been specifically verified such that that the following new tests correctly fail without the fix in place:For attached, enabled, editable field without click handler returns falseFor attached, enabled, editable field with removed click handler returns falseThe first one perfectly covers the case that caused the regression, so these tests should help ensure the regression doesn't occur again.
Additionally, the tests in RaspberryPiFoundation/blockly-keyboard-experimentation#527 have been verified against this PR via linking and verified to pass.
I've manually tested the scenarios involving quotes (since that was the direct failure case) in the keyboard navigation plugin test environment and placed some similar blocks in core Blockly's simple playground (while checking console logs) to verify nothing obvious is broken.
Documentation
No new documentation changes should be needed.
Additional Information
This is a fix suggested over chat by @gonfunko when helping to investigate why the new test was found failing. Note that this failure is a discrepancy between beta.7 and the full 12.0.0 release.