Skip to content

Commit

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

Implement Focus and blur, by using commands.

Changelog: [Internal]

Reviewed By: dmytrorykun

Differential Revision: D52383997
  • Loading branch information
RSNara authored and facebook-github-bot committed Jan 10, 2024
1 parent abae887 commit 697d406
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 697d406

Please sign in to comment.