Skip to content

Commit 81d73b6

Browse files
author
Gökay Şatır
committed
Comments Section: Ensure comment heights are calculated and up to date.
Issue: cachedCommentHeight may hold old value. Fix (2 steps): * Ensure that a relayout action is proessed even if there are consecutive calls to update with differnet "reLayout" boolean values. * Update the cached height of the comment to make sure that the correct height is read while layouting. Signed-off-by: Gökay Şatır <gokay.satir@collabora.com> Change-Id: I191dd539fdf8288284f0664adb7dbc7ab2a5be65
1 parent ae01d7e commit 81d73b6

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

browser/src/canvas/sections/CommentListSection.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ export class CommentSection extends CanvasSectionObject {
13231323
this.setThreadPopup(this.sectionProperties.selectedComment, false);
13241324
this.sectionProperties.showSelectedBigger = false;
13251325
}
1326-
1326+
13271327
const previouslySelectedComment = this.sectionProperties.selectedComment;
13281328
this.sectionProperties.selectedComment = null;
13291329
if (app.map._docLayer._docType !== 'spreadsheet') {
@@ -2539,18 +2539,22 @@ export class CommentSection extends CanvasSectionObject {
25392539
}
25402540

25412541
private update (reLayout: boolean = true): void {
2542-
this.sectionProperties.reLayout = reLayout;
2542+
if (reLayout)
2543+
this.sectionProperties.reLayout = true;
25432544
this.updateDOM();
25442545
}
25452546

25462547
private updateDOM(): void {
25472548
if (!this.sectionProperties.firstImport) return;
25482549

25492550
app.layoutingService.appendLayoutingTask(() => {
2550-
if (this.sectionProperties.reLayout && app.map._docLayer._docType === 'text')
2551+
const reLayout = this.sectionProperties.reLayout;
2552+
this.sectionProperties.reLayout = false;
2553+
2554+
if (reLayout && app.map._docLayer._docType === 'text')
25512555
this.updateThreadInfoIndicator();
25522556

2553-
this.layout(this.sectionProperties.reLayout);
2557+
this.layout(reLayout);
25542558
});
25552559

25562560
app.sectionContainer.requestReDraw();
@@ -2733,8 +2737,19 @@ export class CommentSection extends CanvasSectionObject {
27332737
maxSize += moveUp;
27342738
}
27352739
}
2736-
if (maxSize > minMaxHeight)
2737-
this.sectionProperties.commentList[i].sectionProperties.contentNode.style.maxHeight = Math.round(maxSize) + 'px';
2740+
if (maxSize > minMaxHeight) {
2741+
const comment = this.sectionProperties.commentList[i];
2742+
const contentNode = comment.sectionProperties.contentNode;
2743+
const oldMaxHeight = parseFloat(contentNode.style.maxHeight) || minMaxHeight;
2744+
contentNode.style.maxHeight = Math.round(maxSize) + 'px';
2745+
2746+
// Without this, a later layout(false) would reuse a stale value.
2747+
if (comment.cachedCommentHeight !== null) {
2748+
const oldContent = Math.min(actHeight, oldMaxHeight);
2749+
const newContent = Math.min(actHeight, maxSize);
2750+
comment.cachedCommentHeight += newContent - oldContent;
2751+
}
2752+
}
27382753
}
27392754
}
27402755
}

0 commit comments

Comments
 (0)