Skip to content

Commit

Permalink
fix(GuideBanner): address avt failure (carbon-design-system#5421)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgallo authored Jun 5, 2024
1 parent bea97b4 commit 3b244e6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Button, IconButton } from '@carbon/react';
import { Carousel } from '../Carousel';
import { getDevtoolsProps } from '../../global/js/utils/devtools';
import { pkg } from '../../settings';
import uuidv4 from '../../global/js/utils/uuidv4';

// The block part of our conventional BEM class names (blockClass__E--M).
const blockClass = `${pkg.prefix}--guidebanner`;
Expand Down Expand Up @@ -117,11 +118,12 @@ export let Guidebanner = React.forwardRef<HTMLDivElement, GuidebannerProps>(
const handleClickToggle = () => {
setIsCollapsed((prevState) => !prevState);
};
const carouselContentId = `${uuidv4()}--carousel-content-id`;

return (
<div
{...rest}
aria-expanded={!isCollapsed}
aria-owns={!isCollapsed ? carouselContentId : undefined}
className={cx(
blockClass,
className,
Expand All @@ -135,6 +137,7 @@ export let Guidebanner = React.forwardRef<HTMLDivElement, GuidebannerProps>(
<Idea size={20} className={`${blockClass}__icon-idea`} />
<div className={`${blockClass}__title`}>{title}</div>
<Carousel
id={carouselContentId}
className={`${blockClass}__carousel`}
// These colors are to match the Carousel's faded edges
// against the Guidebanner's gradient background.
Expand All @@ -161,6 +164,8 @@ export let Guidebanner = React.forwardRef<HTMLDivElement, GuidebannerProps>(
className={`${blockClass}__toggle-button`}
onClick={handleClickToggle}
ref={toggleRef}
aria-controls={!isCollapsed ? carouselContentId : undefined}
aria-expanded={!isCollapsed}
>
{isCollapsed ? expandButtonLabel : collapseButtonLabel}
</Button>
Expand Down

0 comments on commit 3b244e6

Please sign in to comment.