-
Notifications
You must be signed in to change notification settings - Fork 23
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
Readonly disappears forever if window is resized while not readonly #78
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Bump to keep from being stale. |
the fix to blockly is merged at google/blockly#5997, just need this half. |
bump to keep from being stale. |
markfinn
added a commit
to markfinn/ngx-blockly
that referenced
this issue
Apr 8, 2022
…never see the readonly workspace again unless you call Blockly.svgResize again. fixes roroettg#78
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If anything calls
Blockly.svgResize
while readonly is false you will never see the readonly workspace again unless you callBlockly.svgResize
again.Blockly.svgResize
is called a lot in my code for dynamic reflows, but it's also easy to trigger in NGX-Blockly itself by resizing the browser window.The cause is that when the
secondaryContainer
div is hidden it will report a size of 0x0 andBlockly.svgResize
will smash the blockly workspace down to that invisible size. That's fine while hidden, but when you un-hide, the SVG workspace is still 0x0. The fix is to callsvgResize
after removing thehidden
class fromsecondaryContainer
:public setReadonly(readOnly: boolean) { this.readOnly = readOnly; if (readOnly) { this.secondaryContainer.nativeElement.classList.remove('hidden'); if (!this._secondaryWorkspace) { const config = {...this.config}; config.readOnly = true; this._secondaryWorkspace = Blockly.inject(this.secondaryContainer.nativeElement, config); } Blockly.Xml.clearWorkspaceAndLoadFromXml(Blockly.Xml.textToDom(this.toXml()), this._secondaryWorkspace); + Blockly.svgResize(this._secondaryWorkspace); } else { if (this._secondaryWorkspace) { this.secondaryContainer.nativeElement.classList.add('hidden');
Note that this fix alone actually doesn't work yet because of a Blockly issue but I have a fix requested over there too. At the moment I have both this change and that one monkey-patched in and everything works as expected when the widows is resized in either state.
Thanks!
The text was updated successfully, but these errors were encountered: