Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWA-3107::There's no message to inform the user the page refreshed it… #4100

Merged
merged 5 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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