Skip to content

Commit

Permalink
Fixed autolayout error related to Placeholder (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdeep authored Jul 27, 2023
1 parent 1cb1eff commit 34c484e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Proton/Sources/Swift/Core/RichTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,16 @@ class RichTextView: AutogrowingTextView {
placeholderLabel.removeFromSuperview()
addSubview(placeholderLabel)
placeholderLabel.attributedText = placeholderText

let placeholderLabelWidthConstraint = placeholderLabel.widthAnchor.constraint(equalTo: self.widthAnchor, constant: -textContainer.lineFragmentPadding - textContainerInset.right)
placeholderLabelWidthConstraint.priority = .defaultHigh

NSLayoutConstraint.activate([
placeholderLabel.topAnchor.constraint(equalTo: self.topAnchor, constant: textContainerInset.top),
placeholderLabel.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -textContainerInset.bottom),
placeholderLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: textContainer.lineFragmentPadding + textContainerInset.left),
placeholderLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -textContainer.lineFragmentPadding),
placeholderLabel.widthAnchor.constraint(equalTo: self.widthAnchor, constant: -textContainer.lineFragmentPadding - textContainerInset.right)
placeholderLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -textContainer.lineFragmentPadding - textContainerInset.right),
placeholderLabelWidthConstraint
])
}

Expand Down

0 comments on commit 34c484e

Please sign in to comment.