Skip to content

Commit 06d880e

Browse files
committed
- Fixed #2042 where in some cases (in react native) the content scrollview was not restored back to original position.
1 parent 4c8a138 commit 06d880e

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

IQKeyboardManagerSwift/Configuration/IQActiveConfiguration.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ internal final class IQActiveConfiguration {
6868

6969
private func sendEvent() {
7070

71-
if let textFieldViewInfo = textFieldViewInfo,
72-
let rootControllerConfiguration = rootControllerConfiguration,
71+
if let rootControllerConfiguration = rootControllerConfiguration,
7372
rootControllerConfiguration.isReady {
7473
if keyboardInfo.keyboardShowing {
7574
if lastEvent == .hide {
@@ -87,13 +86,6 @@ internal final class IQActiveConfiguration {
8786
}, completion: nil)
8887
}
8988
}
90-
} else if textFieldViewInfo == nil, let rootControllerConfiguration = rootControllerConfiguration {
91-
if rootControllerConfiguration.hasChanged {
92-
animate(alongsideTransition: {
93-
rootControllerConfiguration.restore()
94-
}, completion: nil)
95-
}
96-
self.rootControllerConfiguration = nil
9789
}
9890
}
9991

@@ -190,7 +182,7 @@ extension IQActiveConfiguration {
190182

191183
typealias ConfigurationCompletion = (_ event: Event,
192184
_ keyboardInfo: IQKeyboardInfo,
193-
_ textFieldInfo: IQTextFieldViewInfo) -> Void
185+
_ textFieldInfo: IQTextFieldViewInfo?) -> Void
194186

195187
func registerChange(identifier: AnyHashable, changeHandler: @escaping ConfigurationCompletion) {
196188
changeObservers[identifier] = changeHandler
@@ -200,7 +192,7 @@ extension IQActiveConfiguration {
200192
changeObservers[identifier] = nil
201193
}
202194

203-
private func notify(event: Event, keyboardInfo: IQKeyboardInfo, textFieldViewInfo: IQTextFieldViewInfo) {
195+
private func notify(event: Event, keyboardInfo: IQKeyboardInfo, textFieldViewInfo: IQTextFieldViewInfo?) {
204196
lastEvent = event
205197

206198
for block in changeObservers.values {

IQKeyboardManagerSwift/IQKeyboardManager/IQKeyboardManager+Position.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ public extension IQKeyboardManager {
651651
})
652652

653653
// Restoring the contentOffset of the lastScrollView
654-
if let textFieldView: UIView = activeConfiguration.textFieldViewInfo?.textFieldView,
655-
let lastConfiguration: IQScrollViewConfiguration = lastScrollViewConfiguration {
654+
if let lastConfiguration: IQScrollViewConfiguration = lastScrollViewConfiguration {
655+
let textFieldView: UIView? = activeConfiguration.textFieldViewInfo?.textFieldView
656656

657657
activeConfiguration.animate(alongsideTransition: {
658658

@@ -686,8 +686,8 @@ public extension IQKeyboardManager {
686686
if !scrollView.contentOffset.equalTo(newContentOffset) {
687687

688688
// (Bug ID: #1365, #1508, #1541)
689-
let stackView: UIStackView? = textFieldView.iq.superviewOf(type: UIStackView.self,
690-
belowView: scrollView)
689+
let stackView: UIStackView? = textFieldView?.iq.superviewOf(type: UIStackView.self,
690+
belowView: scrollView)
691691

692692
// (Bug ID: #1901, #1996)
693693
let animatedContentOffset: Bool = stackView != nil ||

0 commit comments

Comments
 (0)