Skip to content

Commit 0a3bcc9

Browse files
Chris Lewisfacebook-github-bot
authored andcommitted
Back out "Genalize focus/blur behavior in JS" (#53979)
Summary: Pull Request resolved: #53979 This reverts a previous change that modified how focus behavior is handled in JavaScript. That change caused hierarchy rows to no longer be focusable, either manually or programmatically as they were before, which in turn broke arrow key navigation in entity lists. Reverting the change restores the expected focus behavior and re-enables proper arrow key functionality within entity lists. Changelog: [Internal] Differential Revision: D83390685 fbshipit-source-id: 165567eceedce5d0a2e664a9ef3070d5a2bf9b67
1 parent a81e94a commit 0a3bcc9

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

packages/react-native/Libraries/Components/TextInput/TextInput.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,6 @@ function InternalTextInput(props: TextInputProps): React.Node {
449449
before we can get to the long term breaking change.
450450
*/
451451
if (instance != null) {
452-
// Register the input immediately when the ref is set so that focus()
453-
// can be called from ref callbacks
454-
// Double registering during useLayoutEffect is fine, because the underlying
455-
// state is a Set.
456-
TextInputState.registerInput(instance);
457-
458452
// $FlowFixMe[prop-missing] - See the explanation above.
459453
// $FlowFixMe[unsafe-object-assign]
460454
Object.assign(instance, {

packages/react-native/Libraries/Components/View/ViewNativeComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const ViewNativeComponent: HostComponent<Props> =
2121
}));
2222

2323
interface NativeCommands {
24-
+focus: (viewRef: HostInstance) => void;
25-
+blur: (viewRef: HostInstance) => void;
24+
+focus: () => void;
25+
+blur: () => void;
2626
+hotspotUpdate: (viewRef: HostInstance, x: number, y: number) => void;
2727
+setPressed: (viewRef: HostInstance, pressed: boolean) => void;
2828
}

packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/__tests__/ReactFabricPublicInstance-itest.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1414
import type {HostInstance} from 'react-native';
1515

1616
import ReactNativeElement from '../../../../src/private/webapis/dom/nodes/ReactNativeElement';
17-
import TextInput from '../../../Components/TextInput/TextInput';
1817
import TextInputState from '../../../Components/TextInput/TextInputState';
1918
import View from '../../../Components/View/View';
2019
import ReactFabricHostComponent from '../ReactFabricHostComponent';
@@ -49,7 +48,7 @@ describe('ReactFabricPublicInstance', () => {
4948
const nodeRef = createRef<HostInstance>();
5049

5150
Fantom.runTask(() => {
52-
root.render(<TextInput ref={nodeRef} />);
51+
root.render(<View ref={nodeRef} />);
5352
});
5453

5554
const node = nullthrows(nodeRef.current);
@@ -74,7 +73,7 @@ describe('ReactFabricPublicInstance', () => {
7473
const ref = createRef<HostInstance>();
7574

7675
Fantom.runTask(() => {
77-
root.render(<TextInput ref={ref} />);
76+
root.render(<View ref={ref} />);
7877
});
7978

8079
const node = nullthrows(ref.current);

packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ import type {InstanceHandle} from './internals/NodeInternals';
2525
import type ReactNativeDocument from './ReactNativeDocument';
2626

2727
import TextInputState from '../../../../../Libraries/Components/TextInput/TextInputState';
28-
import {Commands as ViewCommands} from '../../../../../Libraries/Components/View/ViewNativeComponent';
2928
import {create as createAttributePayload} from '../../../../../Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload';
3029
import warnForStyleProps from '../../../../../Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps';
31-
import * as ReactNativeFeatureFlags from '../../../featureflags/ReactNativeFeatureFlags';
3230
import {
3331
getNativeElementReference,
3432
getPublicInstanceFromInstanceHandle,
@@ -142,19 +140,11 @@ class ReactNativeElement extends ReadOnlyElement implements NativeMethods {
142140
*/
143141

144142
blur(): void {
145-
if (TextInputState.isTextInput(this)) {
146-
TextInputState.blurTextInput(this);
147-
} else if (ReactNativeFeatureFlags.enableImperativeFocus()) {
148-
ViewCommands.blur(this);
149-
}
143+
TextInputState.blurTextInput(this);
150144
}
151145

152146
focus() {
153-
if (TextInputState.isTextInput(this)) {
154-
TextInputState.focusTextInput(this);
155-
} else if (ReactNativeFeatureFlags.enableImperativeFocus()) {
156-
ViewCommands.focus(this);
157-
}
147+
TextInputState.focusTextInput(this);
158148
}
159149

160150
measure(callback: MeasureOnSuccessCallback) {

0 commit comments

Comments
 (0)