react-native-keyboard-controller 1.19.0 → 1.19.2

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.
@@ -221,4 +221,17 @@ class KCTextInputCompositeDelegate: NSObject, UITextViewDelegate, UITextFieldDel
221
221
  }
222
222
  return super.forwardingTarget(for: aSelector)
223
223
  }
224
+
225
+ override func doesNotRecognizeSelector(_ aSelector: Selector!) {
226
+ let className = NSStringFromClass(type(of: self))
227
+ let selectorName = NSStringFromSelector(aSelector)
228
+
229
+ print("⚠️ [\(className)] does not recognize selector: \(selectorName)")
230
+
231
+ if let delegate = activeDelegate {
232
+ print("ℹ️ activeDelegate: \(type(of: delegate)) (responds: \(delegate.responds(to: aSelector)))")
233
+ } else {
234
+ print("ℹ️ activeDelegate is nil")
235
+ }
236
+ }
224
237
  }
@@ -11,6 +11,11 @@ import UIKit
11
11
 
12
12
  public extension UITextInput {
13
13
  var canSelectionFitIntoLayout: Bool {
14
+ guard let textView = self as? UITextView else { return true }
15
+
16
+ // Force layout to ensure accurate rect calculation
17
+ textView.layoutManager.ensureLayout(for: textView.textContainer)
18
+
14
19
  guard let selectedRange = selectedTextRange else { return false }
15
20
 
16
21
  guard let range = textRange(from: selectedRange.start, to: selectedRange.end) else { return false }
@@ -14,6 +14,8 @@ import UIKit
14
14
  final class KeyboardTrackingView: UIView {
15
15
  private var keyboardView: UIView? { KeyboardViewLocator.shared.resolve() }
16
16
  private var keyboardHeight = 0.0
17
+ private weak var currentAttachedView: UIView?
18
+ private var isAttaching = false
17
19
 
18
20
  static let invalidPosition: CGFloat = -.greatestFiniteMagnitude
19
21
 
@@ -54,30 +56,42 @@ final class KeyboardTrackingView: UIView {
54
56
  name: UIResponder.keyboardDidShowNotification,
55
57
  object: nil
56
58
  )
59
+ attachToTopmostView()
60
+ }
57
61
 
58
- guard
59
- let window = UIApplication.shared.activeWindow,
60
- let rootView = window.rootViewController?.view
61
- else {
62
- return
62
+ override func willMove(toWindow newWindow: UIWindow?) {
63
+ // When the view is being removed from the window, we need to re-attach it
64
+ if newWindow == nil, !isAttaching {
65
+ attachToTopmostView()
63
66
  }
67
+ }
68
+
69
+ @objc private func attachToTopmostView() {
70
+ guard let topView = UIApplication.topViewController()?.view else { return }
64
71
 
65
- rootView.addSubview(self)
72
+ if currentAttachedView === topView { return }
73
+
74
+ isAttaching = true
75
+ removeFromSuperview()
76
+
77
+ topView.addSubview(self)
78
+ currentAttachedView = topView
66
79
 
67
80
  translatesAutoresizingMaskIntoConstraints = false
68
81
 
69
82
  if #available(iOS 15.0, *) {
70
83
  if #available(iOS 17.0, *) {
71
- rootView.keyboardLayoutGuide.usesBottomSafeArea = false
84
+ topView.keyboardLayoutGuide.usesBottomSafeArea = false
72
85
  }
73
86
 
74
87
  NSLayoutConstraint.activate([
75
- leadingAnchor.constraint(equalTo: rootView.leadingAnchor, constant: 0),
76
- trailingAnchor.constraint(equalTo: rootView.trailingAnchor, constant: 0),
77
- bottomAnchor.constraint(equalTo: rootView.keyboardLayoutGuide.topAnchor, constant: 0),
88
+ leadingAnchor.constraint(equalTo: topView.leadingAnchor, constant: 0),
89
+ trailingAnchor.constraint(equalTo: topView.trailingAnchor, constant: 0),
90
+ bottomAnchor.constraint(equalTo: topView.keyboardLayoutGuide.topAnchor, constant: 0),
78
91
  heightAnchor.constraint(equalToConstant: 0),
79
92
  ])
80
93
  }
94
+ isAttaching = false
81
95
  }
82
96
 
83
97
  @objc private func keyboardWillAppear(_ notification: Notification) {
@@ -113,6 +127,9 @@ final class KeyboardTrackingView: UIView {
113
127
 
114
128
  // for `keyboardLayoutGuide` case we can just read keyboard position directly - no interpolation needed
115
129
  if #available(iOS 26.0, *) {
130
+ if keyboardPosition > keyboardHeight {
131
+ return Self.invalidPosition
132
+ }
116
133
  // when we are the top position KVO takes `inputAccessoryView` into consideration,
117
134
  // so we handle it here
118
135
  if keyboardPosition == keyboardHeight {
@@ -70,7 +70,7 @@ private class BaseContainerView: UIInputView {
70
70
  // Override in subclasses
71
71
  }
72
72
 
73
- override public var intrinsicContentSize: CGSize {
73
+ override var intrinsicContentSize: CGSize {
74
74
  return CGSize(width: UIView.noIntrinsicMetric, height: frame.height)
75
75
  }
76
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.19.0",
3
+ "version": "1.19.2",
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",
@@ -41,7 +41,7 @@
41
41
  "typescript": "tsc --noEmit --project tsconfig.build.json",
42
42
  "lint": "eslint --quiet \"**/*.{js,ts,tsx}\"",
43
43
  "lint-clang": "find ios/ -iname *.h -o -iname *.m -o -iname *.mm | grep -v -e Pods -e build | xargs clang-format -i -n --Werror",
44
- "prepare": "bob build",
44
+ "prepare": "bob build > /dev/null 2>&1",
45
45
  "release": "release-it",
46
46
  "example": "yarn --cwd example",
47
47
  "pods": "cd example && pod-install --quiet",
@@ -85,8 +85,8 @@
85
85
  },
86
86
  "devDependencies": {
87
87
  "@commitlint/config-conventional": "^11.0.0",
88
- "@react-native/babel-preset": "0.80.1",
89
- "@react-native/eslint-config": "0.80.1",
88
+ "@react-native/babel-preset": "0.81.4",
89
+ "@react-native/eslint-config": "0.81.4",
90
90
  "@release-it/conventional-changelog": "^2.0.0",
91
91
  "@testing-library/react-hooks": "^8.0.1",
92
92
  "@types/jest": "^29.5.13",
@@ -112,12 +112,12 @@
112
112
  "pod-install": "^0.1.0",
113
113
  "prettier": "^2.8.8",
114
114
  "react": "19.1.0",
115
- "react-native": "0.80.1",
115
+ "react-native": "0.81.4",
116
116
  "react-native-builder-bob": "^0.18.0",
117
- "react-native-reanimated": "3.17.0",
117
+ "react-native-reanimated": "3.19.2",
118
118
  "react-test-renderer": "19.0.0",
119
119
  "release-it": "^14.2.2",
120
- "typescript": "5.6.3"
120
+ "typescript": "5.8.3"
121
121
  },
122
122
  "peerDependencies": {
123
123
  "react": "*",