Skip to content

Commit

Permalink
Merge branch 'develop' into PWA-3122
Browse files Browse the repository at this point in the history
  • Loading branch information
glo82145 authored May 19, 2023
2 parents b815dee + 87358c7 commit 750f8d5
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ exports[`Should disable delete icon while loading 1`] = `
</svg>
</span>
</button>
<span
aria-hidden="false"
aria-live="polite"
className="hide"
role="status"
>
There is only one item left in your cart
</span>
</div>
`;

Expand Down Expand Up @@ -315,6 +323,14 @@ exports[`Should render correctly 1`] = `
</svg>
</span>
</button>
<span
aria-hidden="false"
aria-live="polite"
className="hide"
role="status"
>
There is only one item left in your cart
</span>
</div>
`;

Expand Down Expand Up @@ -474,6 +490,14 @@ exports[`Should render correctly when configured to use variant thumbnail 1`] =
</svg>
</span>
</button>
<span
aria-hidden="false"
aria-live="polite"
className="hide"
role="status"
>
There is only one item left in your cart
</span>
</div>
`;

Expand Down Expand Up @@ -633,5 +657,13 @@ exports[`Should render correctly with out of stock product 1`] = `
</svg>
</span>
</button>
<span
aria-hidden="false"
aria-live="polite"
className="hide"
role="status"
>
There is only one item left in your cart
</span>
</div>
`;
16 changes: 15 additions & 1 deletion packages/venia-ui/lib/components/MiniCart/ProductList/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const Item = props => {
prices,
closeMiniCart,
configurableThumbnailSource,
storeUrlSuffix
storeUrlSuffix,
totalQuantity
} = props;

const { formatMessage } = useIntl();
Expand Down Expand Up @@ -62,6 +63,11 @@ const Item = props => {
});
const buttonStatus = isDeleting ? minicartButtonDeleted : miniCartButton;

const announceCartCount =
totalQuantity > 1
? 'There are ' + totalQuantity + ' items left in your cart'
: 'There is only one item left in your cart';

return (
<div className={rootClass} data-cy="MiniCart-Item-root">
<Link
Expand Down Expand Up @@ -133,6 +139,14 @@ const Item = props => {
}}
/>
</button>
<span
className={classes.hide}
role="status"
aria-hidden="false"
aria-live="polite"
>
{announceCartCount}
</span>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@
grid-column: 3 / span 1;
grid-row: 1 / span 1;
}

.hide {
visibility: hidden;
max-width: 1px;
max-height: 1px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const ProductList = props => {
classes: propClasses,
closeMiniCart,
configurableThumbnailSource,
storeUrlSuffix
storeUrlSuffix,
totalQuantity
} = props;
const classes = useStyle(defaultClasses, propClasses);

Expand All @@ -27,6 +28,7 @@ const ProductList = props => {
handleRemoveItem={handleRemoveItem}
configurableThumbnailSource={configurableThumbnailSource}
storeUrlSuffix={storeUrlSuffix}
totalQuantity={totalQuantity}
/>
));
}
Expand All @@ -35,7 +37,8 @@ const ProductList = props => {
handleRemoveItem,
closeMiniCart,
configurableThumbnailSource,
storeUrlSuffix
storeUrlSuffix,
totalQuantity
]);

return (
Expand Down
11 changes: 11 additions & 0 deletions packages/venia-ui/lib/components/MiniCart/miniCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const MiniCart = React.forwardRef((props, ref) => {

const [, { addToast }] = useToasts();

const announceMiniCartCount = 'There are no items in your cart.';

useEffect(() => {
if (errorMessage) {
addToast({
Expand Down Expand Up @@ -116,6 +118,14 @@ const MiniCart = React.forwardRef((props, ref) => {
id={'miniCart.emptyMessage'}
defaultMessage={'There are no items in your cart.'}
/>
<span
hidden
role="status"
aria-hidden="false"
aria-live="polite"
>
{announceMiniCartCount}
</span>
</div>
</div>
) : (
Expand All @@ -129,6 +139,7 @@ const MiniCart = React.forwardRef((props, ref) => {
closeMiniCart={closeMiniCart}
configurableThumbnailSource={configurableThumbnailSource}
storeUrlSuffix={storeUrlSuffix}
totalQuantity={totalQuantity}
/>
</div>
<div className={classes.footer}>
Expand Down

0 comments on commit 750f8d5

Please sign in to comment.