fix: show updated field value after editing in horizontal blocks#3351
Open
asdsteven wants to merge 2 commits intoscratchfoundation:developfrom
Open
fix: show updated field value after editing in horizontal blocks#3351asdsteven wants to merge 2 commits intoscratchfoundation:developfrom
asdsteven wants to merge 2 commits intoscratchfoundation:developfrom
Conversation
Problem: In horizontal blocks, let's say you created a control_repeat block, if you edit the number of iteration from 4 to 5, after pressing Enter, the number is still shown as 4. Cause: field.js setText function would call forceRerender. Currently, forceRerender would set this.size_.width to 0 to force a render_() call later. However, this would work only if this.getSize() is indeed called later to trigger this.render_(), which is the case for vertical blocks, but not for horizontal blocks, causing the updated value not being shown. Fix: Setting this.size_.width to 0 was a silly trick. Since our purpose is to force render_() anyway, we could have simply called render_() directly. One may argue that, render_() should not be called immediately; some setup from sourceBlock_.render() needs to be done before this.render_() maybe called. Well, this is not true. this.render_() does not depend on sourceBlock_, or anything. We can just call it immediately.
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem:
In horizontal blocks, let's say you created a control_repeat block, if you edit the number of iteration from 4 to 5, after pressing Enter, the number is still shown as 4.
Cause:
field.js setText function would call forceRerender. Currently, forceRerender would set this.size_.width to 0 to force a render_() call later. However, this would work only if this.getSize() is indeed called later to trigger this.render_(), which is the case for vertical blocks, but not for horizontal blocks, causing the updated value not being shown.
Fix:
Setting this.size_.width to 0 was a silly trick. Since our purpose is to force render_() anyway, we could have simply called render_() directly. One may argue that, render_() should not be called immediately; some setup from sourceBlock_.render() needs to be done before this.render_() maybe called. Well, this is not true. this.render_() does not depend on sourceBlock_, or anything. We can just call it immediately.