Skip to content

Commit d34032b

Browse files
kirillzyuskorobhogan
authored andcommitted
fix: do not overwrite external inputAccessoryView on Fabric (#48339)
Summary: If 3rd party libs are using `inputAccessoryView` - the current code can easily break it. Whenever props gets changed we call `setDefaultInputAccessoryView` which will simply overwrite the current `inputAccessoryView` (which is highly undesirable). The same fix on paper was made ~7 years ago: bf36983 ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [IOS] [FIXED] - Fixed problem with accessory view & 3rd party libs For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: #48339 Test Plan: Make sure `inputAccessoryView` functionality works as before Reviewed By: javache Differential Revision: D67451188 Pulled By: cipolleschi fbshipit-source-id: bc3fa82ae15f8acedfd0b4e17bdea69cbd8c8a8d
1 parent 489b22c commit d34032b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ @implementation RCTTextInputComponentView {
6868
* later comparison insensitive to them.
6969
*/
7070
NSDictionary<NSAttributedStringKey, id> *_originalTypingAttributes;
71+
72+
BOOL _hasInputAccessoryView;
7173
}
7274

7375
#pragma mark - UIView overrides
@@ -610,10 +612,12 @@ - (void)setDefaultInputAccessoryView
610612
keyboardType == UIKeyboardTypeDecimalPad || keyboardType == UIKeyboardTypeASCIICapableNumberPad) &&
611613
(containsKeyType || containsInputAccessoryViewButtonLabel);
612614

613-
if ((_backedTextInputView.inputAccessoryView != nil) == shouldHaveInputAccessoryView) {
615+
if (_hasInputAccessoryView == shouldHaveInputAccessoryView) {
614616
return;
615617
}
616618

619+
_hasInputAccessoryView = shouldHaveInputAccessoryView;
620+
617621
if (shouldHaveInputAccessoryView) {
618622
NSString *buttonLabel = inputAccessoryViewButtonLabel != nil ? inputAccessoryViewButtonLabel
619623
: [self returnKeyTypeToString:returnKeyType];

0 commit comments

Comments
 (0)