Skip to content

Commit e84548f

Browse files
committed
hide behind feature flag
1 parent 601729c commit e84548f

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,18 @@ - (void)didMoveToWindow
127127
{
128128
[super didMoveToWindow];
129129

130-
[_viewController reactRemoveViewControllerAppearanceListener:self];
131-
_viewController = self.window ? [self reactViewController] : nil;
132-
[_viewController reactAddViewControllerAppearanceListener:self];
130+
bool enableNewAutoFocusImpl = ReactNativeFeatureFlags::enableIOSExperimentalAutoFocusImplementation();
131+
if (enableNewAutoFocusImpl) {
132+
[_viewController reactRemoveViewControllerAppearanceListener:self];
133+
_viewController = self.window ? [self reactViewController] : nil;
134+
[_viewController reactAddViewControllerAppearanceListener:self];
135+
}
133136

134137
if (self.window && !_didMoveToWindow) {
135138
_didMoveToWindow = YES;
139+
if (!enableNewAutoFocusImpl) {
140+
[self tryAutoFocus];
141+
}
136142
[self initializeReturnKeyType];
137143
}
138144

@@ -398,9 +404,9 @@ - (void)prepareForRecycle
398404
[_backedTextInputView resignFirstResponder];
399405
}
400406

401-
#pragma mark - RCTViewControllerAppearanceListener
407+
#pragma mark - Auto focus / RCTViewControllerAppearanceListener
402408

403-
- (void)reactViewControllerDidAppear:(UIViewController *)viewController animated:(BOOL)animated
409+
- (void)tryAutoFocus
404410
{
405411
const auto &props = static_cast<const TextInputProps &>(*_props);
406412
if (props.autoFocus && !_didAutoFocus) {
@@ -410,6 +416,11 @@ - (void)reactViewControllerDidAppear:(UIViewController *)viewController animated
410416
}
411417
}
412418

419+
- (void)reactViewControllerDidAppear:(UIViewController *)viewController animated:(BOOL)animated
420+
{
421+
[self tryAutoFocus];
422+
}
423+
413424
#pragma mark - RCTBackedTextInputDelegate
414425

415426
- (BOOL)textInputShouldBeginEditing

0 commit comments

Comments
 (0)