diff --git a/change/@fluentui-react-native-interactive-hooks-d8845be0-8252-468e-9f16-8e4e13ce4a8f.json b/change/@fluentui-react-native-interactive-hooks-d8845be0-8252-468e-9f16-8e4e13ce4a8f.json new file mode 100644 index 0000000000..5bdd17e950 --- /dev/null +++ b/change/@fluentui-react-native-interactive-hooks-d8845be0-8252-468e-9f16-8e4e13ce4a8f.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "win32 has implemented the focus method on UIManager for quite a while at this point", + "packageName": "@fluentui-react-native/interactive-hooks", + "email": "30809111+acoates-ms@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/packages/utils/interactive-hooks/src/useViewCommandFocus.win32.ts b/packages/utils/interactive-hooks/src/useViewCommandFocus.win32.ts deleted file mode 100644 index 211738b16b..0000000000 --- a/packages/utils/interactive-hooks/src/useViewCommandFocus.win32.ts +++ /dev/null @@ -1,41 +0,0 @@ -import * as React from 'react'; -import { findNodeHandle, UIManager } from 'react-native'; - -import type { ViewWin32 } from '@office-iss/react-native-win32'; - -import { setAndForwardRef } from './setAndForwardRef'; - -export type IFocusable = ViewWin32; -/** - * A hook to add an imperative focus method to functional components which simply dispatch a focus command to - * something View-derived on the native side. In practice, this effectively applies to all components in our Win32 - * react native implementation. - * @param forwardRef - The componentRef from your component's props where you're exposing a imperative focus method. - * @returns The inner View-type you're rendering that you want to dispatch to & focus on. - */ -export function useViewCommandFocus( - forwardedRef: React.Ref | undefined, - // initialValue?: React.Component -): (ref: React.ElementRef) => void { - /** - * Set up the forwarding ref to enable adding the focus method. - */ - const focusRef = React.useRef(); - - const _setNativeRef = setAndForwardRef({ - getForwardedRef: () => forwardedRef, - setLocalRef: (localRef: any) => { - focusRef.current = localRef; - - /** - * Add focus() as a callable function to the forwarded reference. - */ - if (localRef) { - localRef.focus = () => { - UIManager.dispatchViewManagerCommand(findNodeHandle(localRef), UIManager.getViewManagerConfig('RCTView').Commands.focus, null); - }; - } - }, - }); - return _setNativeRef; -}