From 2795e257a9c1bb8eb18b3d1e2f60f73f417d719d Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Tue, 17 Jul 2018 12:08:29 -0300 Subject: [PATCH] Fixes an glitch due to contentSize refreshes during layout. --- ios/RNTAztecView/RCTAztecView.swift | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ios/RNTAztecView/RCTAztecView.swift b/ios/RNTAztecView/RCTAztecView.swift index 55215cddd8dec..17664b9e70514 100644 --- a/ios/RNTAztecView/RCTAztecView.swift +++ b/ios/RNTAztecView/RCTAztecView.swift @@ -4,17 +4,24 @@ import Foundation class RCTAztecView: Aztec.TextView { @objc var onContentSizeChange: RCTBubblingEventBlock? = nil + private var previousContentSize: CGSize = .zero + // MARK - View Height: Match to content height - override var contentSize: CGSize { - didSet { - contentSizeChanged() - } + override func layoutSubviews() { + super.layoutSubviews() + + updateContentSizeInRN() } - func contentSizeChanged() { + func updateContentSizeInRN() { let newSize = contentSize + guard previousContentSize != newSize else { + return + } + + previousContentSize = newSize updateHeightToMatch(newSize.height) guard let onContentSizeChange = onContentSizeChange else {