Skip to content

Commit

Permalink
fix: Grid component to properly pass ref to root slot (#20810)
Browse files Browse the repository at this point in the history
* fix: Grid component to properly pass ref to root slot

* add changelog
  • Loading branch information
chpalac authored Nov 30, 2021
1 parent ae9ff9a commit 8cd4834
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/fluentui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ 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 `Grid` component to properly pass ref to root slots @chpalac ([#20810](https://github.com/microsoft/fluentui/pull/20810))
- 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))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Accessibility, GridBehaviorProps } from '@fluentui/accessibility';
import {
ComponentWithAs,
getElementType,
useAccessibility,
useStyles,
useFluentContext,
useTelemetry,
useUnhandledProps,
ForwardRefWithAs,
} from '@fluentui/react-bindings';
import * as customPropTypes from '@fluentui/react-proptypes';
import * as PropTypes from 'prop-types';
Expand Down Expand Up @@ -43,7 +43,7 @@ export type GridStylesProps = Pick<GridProps, 'columns' | 'rows'>;
/**
* A Grid is a layout component that harmonizes negative space, by controlling both the row and column alignment.
*/
export const Grid: ComponentWithAs<'div', GridProps> & FluentComponentStaticProps<GridProps> = props => {
export const Grid = (React.forwardRef<HTMLDivElement, GridProps>((props, ref) => {
const context = useFluentContext();
const { setStart, setEnd } = useTelemetry(Grid.displayName, context.telemetry);
setStart();
Expand Down Expand Up @@ -74,6 +74,7 @@ export const Grid: ComponentWithAs<'div', GridProps> & FluentComponentStaticProp
<ElementType
{...getA11yProps('root', {
className: classes.root,
ref,
...rtlTextContainer.getAttributes({ forElements: [children, content] }),
...unhandledProps,
})}
Expand All @@ -84,7 +85,7 @@ export const Grid: ComponentWithAs<'div', GridProps> & FluentComponentStaticProp
setEnd();

return element;
};
}) as unknown) as ForwardRefWithAs<'div', HTMLDivElement, GridProps> & FluentComponentStaticProps<GridProps>;

Grid.displayName = 'Grid';

Expand Down

0 comments on commit 8cd4834

Please sign in to comment.