Skip to content

Commit

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

* add changelog
  • Loading branch information
chpalac authored Dec 1, 2021
1 parent 6989d22 commit ef05f56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/fluentui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Fix `MenuItemIcon` to allow icon `size` to be in effect @yuanboxue-amber ([#20803](https://github.com/microsoft/fluentui/pull/20803))
- Fix `Pill` components to properly pass ref to root slots @chpalac ([#20838](https://github.com/microsoft/fluentui/pull/20838))
- Fix `MenuButton` component to properly pass ref to root slots @chpalac ([#20837](https://github.com/microsoft/fluentui/pull/20837))
- Fix `Video` component to properly pass ref to root slots @chpalac ([#20878](https://github.com/microsoft/fluentui/pull/20878))

### Features
- Adding `ViewPersonSparkleIcon`, `CartIcon`, and fixing `EmojiAddIcon` and `AccessibilityIcon` - @notandrew ([#20054](https://github.com/microsoft/fluentui/pull/20054))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { Accessibility, VideoBehaviorProps, videoBehavior } from '@fluentui/acce
import { createShorthandFactory, UIComponentProps, commonPropTypes } from '../../utils';
import { FluentComponentStaticProps } from '../../types';
import {
ComponentWithAs,
getElementType,
useStyles,
useFluentContext,
useUnhandledProps,
useTelemetry,
useAccessibility,
ForwardRefWithAs,
} from '@fluentui/react-bindings';

export interface VideoProps extends UIComponentProps {
Expand Down Expand Up @@ -47,7 +47,7 @@ export type VideoStylesProps = Required<Pick<VideoProps, 'variables'>>;
/**
* A Video provides ability to embed video content.
*/
export const Video: ComponentWithAs<'video', VideoProps> & FluentComponentStaticProps<VideoProps> = props => {
export const Video = (React.forwardRef<HTMLVideoElement, VideoProps>((props, ref) => {
const context = useFluentContext();
const { setStart, setEnd } = useTelemetry(Video.displayName, context.telemetry);
setStart();
Expand Down Expand Up @@ -94,6 +94,7 @@ export const Video: ComponentWithAs<'video', VideoProps> & FluentComponentStatic
className: classes.root,
autoPlay,
controls,
ref,
loop,
poster,
src,
Expand All @@ -104,7 +105,7 @@ export const Video: ComponentWithAs<'video', VideoProps> & FluentComponentStatic
);
setEnd();
return element;
};
}) as unknown) as ForwardRefWithAs<'video', HTMLVideoElement, VideoProps> & FluentComponentStaticProps<VideoProps>;

Video.create = createShorthandFactory({ Component: Video, mappedProp: 'src' });

Expand All @@ -124,7 +125,7 @@ Video.propTypes = {
};

Video.defaultProps = {
as: 'video',
as: 'video' as const,
accessibility: videoBehavior,
controls: true,
autoPlay: false,
Expand Down

0 comments on commit ef05f56

Please sign in to comment.