replaces all of our calls to block.render() with block.queueRender().
for the linked bug, here's a timeline of what was happening:
the duplicate function is invoked
appendPrivate is called in Blockly to paste the blocks that are duplicated
the root block (in this case a forever block) starts to initialize which causes its children to be added to the render queue
each of the child blocks is initialized
as part of the function call block's initialization, block.render() is called which immediately flushes the render queue
the blocks in the render queue other than the function call are not actually rendered because they are marked as still initializing, but they are still removed from the queue
the child initialization continues and all of the other blocks except for the math_number are re-added to the queue
initialization completes and the final render takes place
the reason for step 7 where only math_number is left out of the render is pure coincidence caused by the order the blocks are initialized in; i'm sure there are many other setups that would have resulted in the same broken behavior. in any case, the fix is simple: queue the render instead of flushing the queue. i went ahead and made the same change everywhere we call .render() to prevent other similar bugs from cropping up (and hopefully improve perf slightly)
this definitely deserves some extra testing but i did a cursory pass over the affected blocks and fixed the only issue i encountered (the change to the focusLastEditor function in this PR).
fixes https://github.com/microsoft/pxt-microbit/issues/5989
replaces all of our calls to
block.render()
withblock.queueRender()
.for the linked bug, here's a timeline of what was happening:
block.render()
is called which immediately flushes the render queuethe reason for step 7 where only math_number is left out of the render is pure coincidence caused by the order the blocks are initialized in; i'm sure there are many other setups that would have resulted in the same broken behavior. in any case, the fix is simple: queue the render instead of flushing the queue. i went ahead and made the same change everywhere we call
.render()
to prevent other similar bugs from cropping up (and hopefully improve perf slightly)this definitely deserves some extra testing but i did a cursory pass over the affected blocks and fixed the only issue i encountered (the change to the focusLastEditor function in this PR).