fix: Change the truthy tests of width and height in WorkspaceSvg.setCachedParentSvgSize #5997
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 #5930 and possibly #5404
Proposed Changes
Change the truthy tests of width and height in WorkspaceSvg.setCachedParentSvgSize to actual comparisons with null/undefined so that zero value can be saved into the cache
Behavior Before Change
If the div containing the Blockly workspace is hidden and Blockly.svgResize is called you end up in a state where the svg is forced to zero size and it will never some back.
The cause is that during the hidden svgResize WorkspaceSvg.setCachedParentSvgSize fails to record the zero size as noted here #5404 (comment), but the SVG is still made 0x0. Later when the div is un-hidden svgResize doesn't see that the size is growing since the cached value is bad, so the SVG is not set back to a visible size.
The same as what seemed to be noticed in #5404 (comment): change the truthy tests of width and height in WorkspaceSvg.setCachedParentSvgSize to actual comparisons with null so that zero value can be saved into the cache.
Behavior After Change
Zero sizes are saved in to the cache so that they can be noticed later in a comparison when non-zero values become active. Falsey values previously caused entries to not be recorded, but the actual use case is that null/undefined values should not be recorded. Zero does not appear to have been an intentional "no update" trigger.
Reason for Changes
To allow hiding and unhiding of the blockly div to work correctly.
Test Coverage
I've been using this change in chrome for several weeks
Documentation
none
Additional Information
none