-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hiding blockly injection div can break blockly #5930
Labels
Milestone
Comments
Hi @markfinn Given your explanation, that fix sounds great to me! Would you be willing to put up a PR for this? We always really appreciate getting downstream fixes :D Otherwise, hopefully we can get to this in a future bug bash. Either way, thank you so much for reporting this! |
BeksOmega
added
component: rendering
issue: bug
Describes why the code or behaviour is wrong
and removed
issue: triage
Issues awaiting triage by a Blockly team member
labels
Feb 23, 2022
Merged
3 tasks
Took me a while to notice this conversation, but I've made a pull request. Thanks! |
Closed by #5997 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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(907989018), but the SVG is still made 0x0. Later when the div is un-hiddensvgResize
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.A real case of this is using NGX-Blockly which implements a changable readonly input by having two workspaces with one being readonly. That workspace is hidden/un-hidden to transition in and out of read-only mode. If anything calls
Blockly.svgResize
while in read-write mode (in other words while the readonly workspace is in a hidden div) the readonly workspace becomes 0x0 and won't display again even when its div is un-hidden. The problem manifests becauseBlockly.svgResize
gets called in this case if the window is resized due to code in both NGX-Blockly and my own application. In fact in my application it's worse because I also callBlockly.svgResize
for several other reflow events, one of which happens ever time you go into read-write mode.Fix:
The same as what seemed to be noticed in #5404(907989018): 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.I have verified that this does solve my problem, and looking around the rest of Blockly I don't see any places where
WorkspaceSvg.setCachedParentSvgSize
was intentionally not caching based on a non-truthy input other than null.Note that if you use NGX-Blockly to see this then this fix alone is not enough, you also need to re-call
Blockly.svgSize
until a different issue is fixed over there.The text was updated successfully, but these errors were encountered: