fix: comments not being restored when dragging (#6011)

* fix comment deserialization

* add restore comment test

* Fix comment.

* fix: Modify test structure.
This commit is contained in:
YAMADA Yutaka
2022-03-21 23:51:51 +09:00
committed by GitHub
parent e502eaa6e1
commit 85ce3b82c6
4 changed files with 126 additions and 2 deletions

View File

@@ -514,8 +514,13 @@ const loadIcons = function(block, state) {
const comment = state['icons']['comment'];
if (comment) {
block.setCommentText(comment['text']);
block.commentModel.pinned = comment['pinned'];
block.commentModel.size = new Size(comment['width'], comment['height']);
// Load if saved. (Cleaned unnecessary attributes when in the trashcan.)
if ('pinned' in comment) {
block.commentModel.pinned = comment['pinned'];
}
if ('width' in comment && 'height' in comment) {
block.commentModel.size = new Size(comment['width'], comment['height']);
}
if (comment['pinned'] && block.rendered && !block.isInFlyout) {
// Give the block a chance to be positioned and rendered before showing.
const blockSvg = /** @type {!BlockSvg} */ (block);