-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Look into overloaded rendered field on block #4288
Description
Is your feature request related to a problem? Please describe.
Creating a field that forces a re render in the initModel method causes an error when mutating the block. (See example in #3458). This specific instance is fixed, but it is still plausible that someone could create a field that forces a re render which would cause this problem. To recreate Set this.doValueUpdate_ back to setValue.
The reason is that when we mutate the block, we are setting the rendered property on the block to false in an attempt to hold off rendering until the block has been fully created (not doing so will cause #4175). However, setting rendered = false causes the fields init methods to not get called.
When the block is finally ready to be rendered it will go through and call the init methods on all the fields. Since the init methods have not been called before when we reach a field that forces a re render of the entire block(in the example in #4175 this is the field_variable) the fields that have not yet been initialized will throw an error.
Describe the solution you'd like
All this points to our blocks rendered property being overloaded as described in this comment and at the bottom of this comment. By setting some kind of flag for when we are making batch changes to a block we can avoid this issue. However, there are quite a few other issues that are around this that we should look into before deciding.
Describe alternatives you've considered
Additional context