Skip to content

Commit

Permalink
BridgelessUIManager: Finish focus, blur (#42210)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #42210

Implement Focus and blur, by using commands.

Changelog: [Internal]

Reviewed By: dmytrorykun

Differential Revision: D52383997

fbshipit-source-id: ca3c20d77b17147b592cbf3c48772b857a2e2c55
  • Loading branch information
RSNara authored and pull[bot] committed Mar 12, 2024
1 parent 1aa5404 commit df0e166
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions packages/react-native/Libraries/ReactNative/BridgelessUIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,38 @@ const UIManagerJSPlatformAPIs = Platform.select({
return {};
},
focus: (reactTag: ?number): void => {
raiseSoftError('focus');
if (reactTag == null) {
console.error(
`focus() noop: Cannot be called with ${String(reactTag)} reactTag`,
);
return;
}

const FabricUIManager = nullthrows(getFabricUIManager());
const shadowNode =
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
if (!shadowNode) {
console.error(`focus() noop: Cannot find view with tag #${reactTag}`);
return;
}
FabricUIManager.dispatchCommand(shadowNode, 'focus', []);
},
blur: (reactTag: ?number): void => {
raiseSoftError('blur');
if (reactTag == null) {
console.error(
`blur() noop: Cannot be called with ${String(reactTag)} reactTag`,
);
return;
}

const FabricUIManager = nullthrows(getFabricUIManager());
const shadowNode =
FabricUIManager.findShadowNodeByTag_DEPRECATED(reactTag);
if (!shadowNode) {
console.error(`blur() noop: Cannot find view with tag #${reactTag}`);
return;
}
FabricUIManager.dispatchCommand(shadowNode, 'blur', []);
},
},
});
Expand Down

0 comments on commit df0e166

Please sign in to comment.