Skip to content

Commit

Permalink
Fixed performance issue with non-scrollable content (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdeep authored Aug 25, 2023
1 parent df31a9c commit 3c10be0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Proton/Sources/Swift/Attachment/Attachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,10 @@ extension Attachment {
let range = editor.attributedText.rangeFor(attachment: self)
else { return }
cachedBounds = nil
let needsInvalidation = bounds.integral.size != contentView?.bounds.integral.size
editor.invalidateLayout(for: range)

if containerTextView?.isScrollEnabled == false {
if containerTextView?.isScrollEnabled == false, needsInvalidation {
containerTextView?.invalidateIntrinsicContentSize()
}
}
Expand Down
7 changes: 0 additions & 7 deletions Proton/Sources/Swift/Core/RichTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ class RichTextView: AutogrowingTextView {
}
}

override func layoutSubviews() {
super.layoutSubviews()
if editorView?.isRootEditor == true, editorView?.isScrollEnabled == false {
invalidateIntrinsicContentSize()
}
}

override var selectedTextRange: UITextRange? {
didSet{
let old = oldValue?.toNSRange(in: self)
Expand Down
2 changes: 1 addition & 1 deletion Proton/Sources/Swift/Grid/View/GridCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public class GridCell {
}

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

/// Sets the focus in the `Editor` within the cell.
Expand Down

0 comments on commit 3c10be0

Please sign in to comment.