Skip to content

Commit 677cb7d

Browse files
committed
fix: apply patch to RNKC that doesn't attach tracking view to inactive window
1 parent 094e3e5 commit 677cb7d

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

patches/react-native-keyboard-controller/react-native-keyboard-controller+1.20.0+001+loggers-and-visual.patch renamed to patches/react-native-keyboard-controller/react-native-keyboard-controller+1.20.0+001+do-not-attach-to-inactive-window.patch

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,27 @@ index 7120bdb..7dd38bd 100644
2323
var controlPoints: ContiguousArray<Float> = ContiguousArray([0, 0, 0, 0])
2424
timingFunction?.getControlPoint(at: 1, values: &controlPoints[0])
2525
diff --git a/node_modules/react-native-keyboard-controller/ios/observers/movement/KeyboardTrackingView.swift b/node_modules/react-native-keyboard-controller/ios/observers/movement/KeyboardTrackingView.swift
26-
index dc07c23..813b377 100644
26+
index dc07c23..b853808 100644
2727
--- a/node_modules/react-native-keyboard-controller/ios/observers/movement/KeyboardTrackingView.swift
2828
+++ b/node_modules/react-native-keyboard-controller/ios/observers/movement/KeyboardTrackingView.swift
29-
@@ -40,9 +40,11 @@ public final class KeyboardTrackingView: UIView {
30-
31-
private func setup() {
32-
// for debug purposes
33-
- // self.backgroundColor = .red
34-
- isUserInteractionEnabled = false
35-
- isHidden = true
36-
+ self.backgroundColor = .red
37-
+ // 10 px height
38-
+ self.frame = CGRect(x: 0, y: 0, width: 1, height: 2)
39-
+ // isUserInteractionEnabled = false
40-
+ // isHidden = true
41-
42-
NotificationCenter.default.addObserver(
43-
self,
44-
@@ -87,7 +89,7 @@ public final class KeyboardTrackingView: UIView {
45-
leadingAnchor.constraint(equalTo: topView.leadingAnchor, constant: 0),
46-
trailingAnchor.constraint(equalTo: topView.trailingAnchor, constant: 0),
47-
bottomAnchor.constraint(equalTo: topView.keyboardLayoutGuide.topAnchor, constant: 0),
48-
- heightAnchor.constraint(equalToConstant: 0),
49-
+ heightAnchor.constraint(equalToConstant: 2),
50-
])
51-
}
52-
isAttaching = false
29+
@@ -66,7 +66,14 @@ public final class KeyboardTrackingView: UIView {
30+
}
31+
32+
@objc public func attachToTopmostView(toWindow window: UIWindow? = nil) {
33+
- guard let topView = (window?.rootViewController ?? UIApplication.topViewController())?.view else { return }
34+
+ var topViewController = window?.rootViewController
35+
+ if let rootVC = topViewController, let topView = rootVC.view, topView.window != nil {
36+
+ // ok, attach
37+
+ } else {
38+
+ topViewController = UIApplication.topViewController()
39+
+ }
40+
+
41+
+ guard let topView = topViewController?.view else { return }
42+
43+
if currentAttachedView === topView { return }
44+
5345
diff --git a/node_modules/react-native-keyboard-controller/ios/observers/movement/observer/KeyboardMovementObserver+Watcher.swift b/node_modules/react-native-keyboard-controller/ios/observers/movement/observer/KeyboardMovementObserver+Watcher.swift
54-
index 53148a6..4001123 100644
46+
index 53148a6..9a6f078 100644
5547
--- a/node_modules/react-native-keyboard-controller/ios/observers/movement/observer/KeyboardMovementObserver+Watcher.swift
5648
+++ b/node_modules/react-native-keyboard-controller/ios/observers/movement/observer/KeyboardMovementObserver+Watcher.swift
5749
@@ -22,6 +22,8 @@ extension KeyboardMovementObserver {
@@ -72,7 +64,7 @@ index 53148a6..4001123 100644
7264
if keyboardPosition == prevKeyboardPosition || keyboardFrameY == 0 {
7365
return
7466
}
75-
67+
7668
+ print("kav 3")
7769
+
7870
if animation == nil {
@@ -83,7 +75,7 @@ index 53148a6..4001123 100644
8375
@@ -61,6 +68,8 @@ extension KeyboardMovementObserver {
8476
keyboardPosition = race(position, keyboardPosition)
8577
}
86-
78+
8779
+ print("kav 4 \(keyboardPosition)")
8880
+
8981
onEvent(

0 commit comments

Comments
 (0)