Skip to content

Commit 3c10be0

Browse files
authored
Fixed performance issue with non-scrollable content (#219)
1 parent df31a9c commit 3c10be0

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

Diff for: Proton/Sources/Swift/Attachment/Attachment.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,10 @@ extension Attachment {
474474
let range = editor.attributedText.rangeFor(attachment: self)
475475
else { return }
476476
cachedBounds = nil
477+
let needsInvalidation = bounds.integral.size != contentView?.bounds.integral.size
477478
editor.invalidateLayout(for: range)
478479

479-
if containerTextView?.isScrollEnabled == false {
480+
if containerTextView?.isScrollEnabled == false, needsInvalidation {
480481
containerTextView?.invalidateIntrinsicContentSize()
481482
}
482483
}

Diff for: Proton/Sources/Swift/Core/RichTextView.swift

-7
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@ class RichTextView: AutogrowingTextView {
8787
}
8888
}
8989

90-
override func layoutSubviews() {
91-
super.layoutSubviews()
92-
if editorView?.isRootEditor == true, editorView?.isScrollEnabled == false {
93-
invalidateIntrinsicContentSize()
94-
}
95-
}
96-
9790
override var selectedTextRange: UITextRange? {
9891
didSet{
9992
let old = oldValue?.toNSRange(in: self)

Diff for: Proton/Sources/Swift/Grid/View/GridCell.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public class GridCell {
183183
}
184184

185185
public convenience init(rowSpan: [Int], columnSpan: [Int], initialHeight: CGFloat = 40, style: GridCellStyle = .init(), gridStyle: GridStyle = .default) {
186-
self.init(editor: EditorView(), rowSpan: rowSpan, columnSpan: columnSpan, initialHeight: initialHeight, style: style, gridStyle: gridStyle)
186+
self.init(editor: EditorView(allowAutogrowing: false), rowSpan: rowSpan, columnSpan: columnSpan, initialHeight: initialHeight, style: style, gridStyle: gridStyle)
187187
}
188188

189189
/// Sets the focus in the `Editor` within the cell.

0 commit comments

Comments
 (0)