Skip to content

Commit

Permalink
fix: Divider component to properly pass ref (microsoft#20700)
Browse files Browse the repository at this point in the history
* fix: Divider component to properly pass ref

* add changelog
  • Loading branch information
chpalac authored and Marion Le Pontois committed Jan 17, 2022
1 parent c1182cf commit 1481029
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/fluentui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Fix `Card` comoponent to properly pass ref to root slots @chpalac ([#20644](https://github.com/microsoft/fluentui/pull/20644))
- Fix `Dropdown` by conditionally adding `aria-expanded="true"` to the button trigger @chpalac ([#20671](https://github.com/microsoft/fluentui/pull/20671))
- Optimized `felaInvokeKeyframesPlugin` to not create new objects but reuse existing one in `reduce` @mbman ([#20649](https://github.com/microsoft/fluentui/pull/20649))
- Fix `Divider` component to properly pass ref to root slots @chpalac ([#20700](https://github.com/microsoft/fluentui/pull/20700))
- Fix `Dropdown` component to properly pass ref to root slots @chpalac ([#20702](https://github.com/microsoft/fluentui/pull/20702))
- Fix `Checkbox` component to properly pass down ref to root slots @chpalac ([#20696](https://github.com/microsoft/fluentui/pull/20696))
- Fix `Datepicker` components to properly pass ref to root slots @chpalac ([#20697](https://github.com/microsoft/fluentui/pull/20697))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useFluentContext,
useUnhandledProps,
useStyles,
ComponentWithAs,
ForwardRefWithAs,
} from '@fluentui/react-bindings';
import * as React from 'react';
import * as PropTypes from 'prop-types';
Expand Down Expand Up @@ -60,10 +60,7 @@ export const dividerClassName = 'ui-divider';
/**
* A Divider visually segments content.
*/
export const Divider: ComponentWithAs<'div', DividerProps> &
FluentComponentStaticProps<DividerProps> & {
Content: typeof DividerContent;
} = props => {
export const Divider = (React.forwardRef<HTMLDivElement, DividerProps>((props, ref) => {
const context = useFluentContext();
const { setStart, setEnd } = useTelemetry(Divider.displayName, context.telemetry);
setStart();
Expand Down Expand Up @@ -111,6 +108,7 @@ export const Divider: ComponentWithAs<'div', DividerProps> &
<ElementType
{...getA11yProps('root', {
className: classes.root,
ref,
...rtlTextContainer.getAttributes({ forElements: [children] }),
...unhandledProps,
})}
Expand All @@ -120,7 +118,10 @@ export const Divider: ComponentWithAs<'div', DividerProps> &
);
setEnd();
return element;
};
}) as unknown) as ForwardRefWithAs<'div', HTMLDivElement, DividerProps> &
FluentComponentStaticProps<DividerProps> & {
Content: typeof DividerContent;
};

Divider.displayName = 'Divider';

Expand Down

0 comments on commit 1481029

Please sign in to comment.