react-native-keyboard-controller 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,7 +79,7 @@ val EditText.parentScrollViewTarget: Int
79
79
  val parentView = currentView.parent as? View
80
80
 
81
81
  if (parentView is ScrollView) {
82
- // If the parent is a ScrollView, return its id
82
+ // If the parent is a vertical ScrollView, return its id
83
83
  return parentView.id
84
84
  }
85
85
 
@@ -68,8 +68,14 @@ public extension Optional where Wrapped: UIResponder {
68
68
  var currentResponder: UIResponder? = self
69
69
 
70
70
  while let currentView = currentResponder {
71
- // If the current responder is a UIScrollView (excluding UITextView), return its tag
72
- if let scrollView = currentView as? UIScrollView, !(currentView is UITextView) {
71
+ // If the current responder is a vertical UIScrollView (excluding UITextView), return its tag
72
+ if let scrollView = currentView as? UIScrollView,
73
+ !(currentView is UITextView),
74
+ scrollView.contentSize.height > scrollView.frame.size.height
75
+ // it was fixed in swiftlint https://github.com/realm/SwiftLint/issues/3756 but a new release is not available yet
76
+ // swiftlint:disable all
77
+ {
78
+ // swiftlint:enable all
73
79
  return scrollView.reactViewTag
74
80
  }
75
81
 
@@ -95,7 +95,7 @@ public class FocusedInputObserver: NSObject {
95
95
  }
96
96
 
97
97
  @objc func keyboardWillShow(_: Notification) {
98
- let responder = UIResponder.current as? UIView
98
+ guard let responder = UIResponder.current as? UIView else { return }
99
99
  removeObservers(newResponder: responder)
100
100
  currentResponder = responder
101
101
  currentInput = currentResponder?.superview as UIView?
@@ -126,16 +126,18 @@ public class FocusedInputObserver: NSObject {
126
126
  let focusedInput = currentInput
127
127
  let globalFrame = focusedInput?.globalFrame
128
128
 
129
+ guard let frame = globalFrame, let input = focusedInput else { return }
130
+
129
131
  let data: [String: Any] = [
130
132
  "target": responder.reactViewTag,
131
133
  "parentScrollViewTarget": responder.parentScrollViewTarget,
132
134
  "layout": [
133
- "absoluteX": globalFrame?.origin.x,
134
- "absoluteY": globalFrame?.origin.y,
135
- "width": focusedInput?.frame.width,
136
- "height": focusedInput?.frame.height,
137
- "x": focusedInput?.frame.origin.x,
138
- "y": focusedInput?.frame.origin.y,
135
+ "absoluteX": frame.origin.x,
136
+ "absoluteY": frame.origin.y,
137
+ "width": input.frame.width,
138
+ "height": input.frame.height,
139
+ "x": input.frame.origin.x,
140
+ "y": input.frame.origin.y,
139
141
  ],
140
142
  ]
141
143
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "Keyboard manager which works in identical way on both iOS and Android",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",