diff --git a/packages/fluentui/CHANGELOG.md b/packages/fluentui/CHANGELOG.md index ab69a3dc2887e0..4dc987341b950c 100644 --- a/packages/fluentui/CHANGELOG.md +++ b/packages/fluentui/CHANGELOG.md @@ -57,11 +57,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Fix `Chat` components to properly pass ref to root slots @chpalac ([#20691](https://github.com/microsoft/fluentui/pull/20691)) - Fix `Flex` component to properly pass ref to root slots @chpalac ([#20752](https://github.com/microsoft/fluentui/pull/20752)) - Fix `Animation` to expose `Transition` state for the consumer @chpalac ([#20776](https://github.com/microsoft/fluentui/pull/20776)) +- Fix `Form` components to properly pass ref to root slots @chpalac ([#20809](https://github.com/microsoft/fluentui/pull/20809)) - Fix `Loader` component to properly pass ref to root slots @chpalac ([#20814](https://github.com/microsoft/fluentui/pull/20814)) - Fix `Label` component to properly pass ref to root slots @chpalac ([#20813](https://github.com/microsoft/fluentui/pull/20813)) - Fix `MenuItemIcon` to allow icon `size` to be in effect @yuanboxue-amber ([#20803](https://github.com/microsoft/fluentui/pull/20803)) - ### Features - Adding `ViewPersonSparkleIcon`, `CartIcon`, and fixing `EmojiAddIcon` and `AccessibilityIcon` - @notandrew ([#20054](https://github.com/microsoft/fluentui/pull/20054)) diff --git a/packages/fluentui/react-northstar/src/components/Form/Form.tsx b/packages/fluentui/react-northstar/src/components/Form/Form.tsx index aff28b7c98dac0..dc3ee41afea980 100644 --- a/packages/fluentui/react-northstar/src/components/Form/Form.tsx +++ b/packages/fluentui/react-northstar/src/components/Form/Form.tsx @@ -15,13 +15,13 @@ import { import { ComponentEventHandler, ShorthandCollection, FluentComponentStaticProps } from '../../types'; import { FormField, FormFieldProps } from './FormField'; import { - ComponentWithAs, useTelemetry, getElementType, useUnhandledProps, useStyles, useFluentContext, useAccessibility, + ForwardRefWithAs, } from '@fluentui/react-bindings'; export interface FormProps extends UIComponentProps, ChildrenComponentProps { @@ -54,7 +54,7 @@ export type FormStylesProps = never; /** * A Form is used to collect, oprionally validate, and submit the user input, in a structured way. */ -export const Form: ComponentWithAs<'form', FormProps> & FluentComponentStaticProps = props => { +export const Form = (React.forwardRef((props, ref) => { const context = useFluentContext(); const { setStart, setEnd } = useTelemetry(Form.displayName, context.telemetry); setStart(); @@ -96,6 +96,7 @@ export const Form: ComponentWithAs<'form', FormProps> & FluentComponentStaticPro & FluentComponentStaticPro ); setEnd(); return element; -}; +}) as unknown) as ForwardRefWithAs<'form', HTMLFormElement, FormProps> & FluentComponentStaticProps; Form.displayName = 'Form'; @@ -121,7 +122,7 @@ Form.propTypes = { }; Form.defaultProps = { - as: 'form', + as: 'form' as const, }; Form.handledProps = Object.keys(Form.propTypes) as any; diff --git a/packages/fluentui/react-northstar/src/components/Form/FormField.tsx b/packages/fluentui/react-northstar/src/components/Form/FormField.tsx index 72730d496a85ce..ef45fcabc7a585 100644 --- a/packages/fluentui/react-northstar/src/components/Form/FormField.tsx +++ b/packages/fluentui/react-northstar/src/components/Form/FormField.tsx @@ -15,13 +15,13 @@ import { Text, TextProps } from '../Text/Text'; import { Input } from '../Input/Input'; import { Box, BoxProps } from '../Box/Box'; import { - ComponentWithAs, getElementType, useUnhandledProps, useFluentContext, useTelemetry, useStyles, useAccessibility, + ForwardRefWithAs, } from '@fluentui/react-bindings'; export interface FormFieldProps extends UIComponentProps, ChildrenComponentProps { @@ -71,7 +71,7 @@ export type FormFieldStylesProps = Required & FluentComponentStaticProps = props => { +export const FormField = (React.forwardRef((props, ref) => { const context = useFluentContext(); const { setStart, setEnd } = useTelemetry(FormField.displayName, context.telemetry); setStart(); @@ -175,6 +175,7 @@ export const FormField: ComponentWithAs<'div', FormFieldProps> & FluentComponent @@ -183,7 +184,7 @@ export const FormField: ComponentWithAs<'div', FormFieldProps> & FluentComponent ); setEnd(); return element; -}; +}) as unknown) as ForwardRefWithAs<'div', HTMLDivElement, FormFieldProps> & FluentComponentStaticProps; FormField.displayName = 'FormField'; diff --git a/packages/fluentui/react-northstar/src/components/Form/FormFieldCustom.tsx b/packages/fluentui/react-northstar/src/components/Form/FormFieldCustom.tsx index ab97650d2aa4ba..8cac8241a7f074 100644 --- a/packages/fluentui/react-northstar/src/components/Form/FormFieldCustom.tsx +++ b/packages/fluentui/react-northstar/src/components/Form/FormFieldCustom.tsx @@ -41,8 +41,7 @@ export type FormFieldCustomStylesProps = Required & - FluentComponentStaticProps = props => { +export const FormFieldCustom = (React.forwardRef((props, ref) => { const context = useFluentContext(); const { setStart, setEnd } = useTelemetry(FormFieldCustom.displayName, context.telemetry); setStart(); @@ -77,6 +76,7 @@ export const FormFieldCustom: React.FC & @@ -85,7 +85,7 @@ export const FormFieldCustom: React.FC & ); setEnd(); return element; -}; +}) as unknown) as React.FC & FluentComponentStaticProps; FormFieldCustom.displayName = 'FormFieldCustom';