fix: Only hide WidgetDiv if it is associated with the affected workspace. #8150
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 google/blockly-samples#2131
Proposed Changes
This associates a workspace with the current
WidgetDiv
, so that when a workspace needs to clean up its chaff, it can detect whether the currentWidgetDiv
is associated with it and only clean it up if it's affected.I added a workspace parameter to
WidgetDiv.show()
andContextMenu.show()
, and ahideIfOwnerIsInWorkspace
method toWorkspaceDiv
. I also updated some calls fromWidgetDiv.hide()
toWidgetDiv.hideIfOwner(this)
.Reason for Changes
In google/blockly-samples#2131 the minimap plugin calls
this.minimapWorkspace.zoomToFit()
in response to changes, which callsWorkspaceSvg.hideChaff()
which calls the static class methodWidgetDiv.hide()
which unfocuses inputs in the main workspace because the input widget is shared between the main workspace and the minimap workspace. Intermediate change events do not trigger the issue, so most text input fields work fine, but standard BlockChange events trigger the issue and editing procedure names and parameters will update caller blocks in the same workspace which fires BlockChange events which will trigger the issue and immediately unfocus the input field after typing a single character.Test Coverage
I manually tested with the minimap plugin to make sure that procedures and procedure parameters could be renamed without immediately losing focus (and that basic widget hiding still seems to work). All existing unit tests pass.
Documentation
N/A