Skip to content

Commit 5b0b4c3

Browse files
authored
fix: attaching KeyboardExtender (#1065)
## 📜 Description Fixed mounting `KeybaordExtender` when switching `enabled` from `false` to `true`. ## 💡 Motivation and Context When initial `enabled={false}` and then we switch it to `true`, then this code: ```tsx if (_sharedInputAccessoryView) { if (!enabled) { [self detachInputAccessoryView]; } else { // Re-attach if a text input is active UIResponder *firstResponder = [UIResponder current]; if ([firstResponder conformsToProtocol:@protocol(UITextInput)]) { [self attachToTextInput:(UIView *)firstResponder]; } ``` Will never be executed. Because `_sharedInputAccessoryView` is `nil` (it's initialized in `attachInputAccessoryViewTo`). To fix this bug I simply removed `if (_sharedInputAccessoryView)` condition - it should work without it too 🙂 Closes #1056 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### iOS - removed `if (_sharedInputAccessoryView)` condition; - cleanup `KeyboardExtenderContainerView` file; ## 🤔 How Has This Been Tested? Tested manually on iPhone 15 Pro (iOS 17.5). ## 📸 Screenshots (if appropriate): https://github.com/user-attachments/assets/6ffc5462-6425-4d32-bef0-99e1f37c06a8 ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 93a55c1 commit 5b0b4c3

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

ios/views/KeyboardExtenderContainerView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ private class BaseContainerView: UIInputView {
5555
if frame.height != desiredHeight {
5656
frame.size.height = desiredHeight
5757

58-
// Update content frame
5958
updateContentFrame(desiredHeight: desiredHeight)
6059

6160
// Trigger layout updates
@@ -105,8 +104,6 @@ private class ModernContainerView: BaseContainerView {
105104
}
106105

107106
override func updateContentFrame(desiredHeight: CGFloat) {
108-
let totalHeight = desiredHeight + paddingBottom
109-
110107
visualEffectView?.frame = CGRect(
111108
x: paddingHorizontal,
112109
y: -paddingBottom,

ios/views/KeyboardExtenderManager.mm

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,13 @@ - (void)updateEnabledState:(BOOL)enabled
244244
{
245245
_enabled = enabled;
246246

247-
if (_sharedInputAccessoryView) {
248-
if (!enabled) {
249-
[self detachInputAccessoryView];
250-
} else {
251-
// Re-attach if a text input is active
252-
UIResponder *firstResponder = [UIResponder current];
253-
if ([firstResponder conformsToProtocol:@protocol(UITextInput)]) {
254-
[self attachToTextInput:(UIView *)firstResponder];
255-
}
247+
if (!enabled) {
248+
[self detachInputAccessoryView];
249+
} else {
250+
// Re-attach if a text input is active
251+
UIResponder *firstResponder = [UIResponder current];
252+
if ([firstResponder conformsToProtocol:@protocol(UITextInput)]) {
253+
[self attachToTextInput:(UIView *)firstResponder];
256254
}
257255
}
258256
}

0 commit comments

Comments
 (0)