Skip to content

Commit

Permalink
feat(GlobalBanner): add forwardRef to GlobalBanner
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbrillant committed Oct 27, 2021
1 parent 58ab4ef commit 993c91b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/react/src/components/global-banner/global-banner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent, MouseEvent, useState } from 'react';
import React, { forwardRef, FunctionComponent, MouseEvent, Ref, useState } from 'react';
import styled, { css, StyledProps } from 'styled-components';
import { useTranslation } from '../../i18n/use-translation';
import { useDeviceContext } from '../device-context-provider/device-context-provider';
Expand Down Expand Up @@ -208,7 +208,7 @@ interface Props {

}

export const GlobalBanner: FunctionComponent<Props> = ({
export const GlobalBanner: FunctionComponent<Props> = forwardRef(({
actionButton,
children,
className,
Expand All @@ -217,7 +217,7 @@ export const GlobalBanner: FunctionComponent<Props> = ({
label,
secondaryActionButton,
type = 'default',
}) => {
}, ref: Ref<HTMLElement>) => {
const { isMobile } = useDeviceContext();
const [visible, setVisible] = useState(!hidden);
const { t } = useTranslation('global-banner');
Expand All @@ -226,6 +226,7 @@ export const GlobalBanner: FunctionComponent<Props> = ({

return visible ? (
<Container
ref={ref}
aria-atomic="true"
aria-live="polite"
className={className}
Expand Down Expand Up @@ -284,4 +285,4 @@ export const GlobalBanner: FunctionComponent<Props> = ({
)}
</Container>
) : null;
};
});

0 comments on commit 993c91b

Please sign in to comment.