티스토리 수익 글 보기
{{ message }}
Fix(embed-block): Only call setAttributes() when attrs change
#68141
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.
What?
Fixes: #61778.
Prevents
setAttributes()from being called whenever the block remounts and no attributes have changed.Why?
Due to the way
setAttributes()currently works and how the embed block calls setAttributes() with a new shallow copy of attributes whenever the block is remounted, the following steps result in an ugly bug:This causes the full set of attributes from the last embed block selected to be set to all the other dragged embed + image blocks, changing them all into duplicate blocks of the last embed block.
The problem is due to a combination of:
setAttributes()updates all passed attributes to all selected blocks, this was intended for mass block option editing. However, this is not always the desired behaviour.setAttributes()using a new shallow copy of the full set of attributes.How?
The current
setAttributes()implementation has desired and undesired effects, and needs to be expanded upon to address the undesired effects. That could indirectly fix this embed block remounting situation.However, the embed block should not be trying to update its attributes upon every block remount.
This PR Prevents the embed block from calling
setAttributes()when no attributes have been changed.Testing Instructions
Without this PR, the image block would get turned into an embed block as its attributes are changed to be the same as the embed block attributes. Causing the image block to fail and then automatically gets converted into an embed block.