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

AC-2487::Accordions do not indicate current state #3977

Merged
merged 11 commits into from
Nov 15, 2022
3 changes: 3 additions & 0 deletions packages/venia-ui/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"filterModal.item.clearFilter": "Remove filter \"{optionName}\".",
"filterModal.item.hideOptions": "Hide \"{itemName}\" filter item options.",
"filterModal.item.showOptions": "Show \"{itemName}\" filter item options.",
"filterModalOpenButton.ariaLabel": "Filter Button for Filter Options.",
"filterSearch.name": "Enter a {name}",
"footer.calloutText": "Lorem ipsum dolor sit amet, consectetur adipsicing elit, sed do eiusmod tempor incididunt ut labore et dolore.",
"footer.followText": "Follow Us!",
Expand Down Expand Up @@ -373,6 +374,8 @@
"productQuantity.label": "product's quantity",
"productSort.sortByButton": "Sort by",
"productSort.sortButton": "Sort",
"productSort.sortButtonCollapsed": "Sort Button Collapsed",
"productSort.sortButtonExpanded": "Sort Button Expanded",
"quantity.buttonDecrement": "Decrease Quantity",
"quantity.buttonIncrement": "Increase Quantity",
"quantity.input": "Item Quantity",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { shape, string, array } from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, useIntl } from 'react-intl';
import Button from '../Button';
import { useStyle } from '../../classify';
import defaultClasses from './filterModalOpenButton.module.css';
Expand All @@ -10,7 +10,12 @@ const FilterModalOpenButton = props => {
const { filters, classes: propsClasses } = props;
const classes = useStyle(defaultClasses, propsClasses);
const { handleOpen } = useFilterModal({ filters });

const handleKeypress = e => {
if (e.code == 'Enter') {
handleOpen;
}
};
const { formatMessage } = useIntl();
return (
<Button
priority={'low'}
Expand All @@ -19,9 +24,14 @@ const FilterModalOpenButton = props => {
}}
data-cy="FilterModalOpenButton-button"
onClick={handleOpen}
onKeyDown={handleKeypress}
type="button"
aria-live="polite"
aria-busy="false"
aria-label={formatMessage({
id: 'filterModalOpenButton.ariaLabel',
defaultMessage: 'Filter Button for Filter Options'
})}
>
<FormattedMessage
id={'productList.filter'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ exports[`it does not render order details if loading is true 1`] = `
/>
</div>
<button
aria-expanded={false}
className="contentToggleContainer"
onClick={[MockFunction handleContentToggle]}
type="button"
Expand Down Expand Up @@ -285,6 +286,7 @@ exports[`it renders collapsed order row 1`] = `
/>
</div>
<button
aria-expanded={false}
className="contentToggleContainer"
onClick={[MockFunction handleContentToggle]}
type="button"
Expand Down Expand Up @@ -571,6 +573,7 @@ exports[`it renders open order row 1`] = `
/>
</div>
<button
aria-expanded={true}
className="contentToggleContainer"
onClick={[MockFunction handleContentToggle]}
type="button"
Expand Down Expand Up @@ -867,6 +870,7 @@ exports[`it renders with missing order information 1`] = `
/>
</div>
<button
aria-expanded={false}
className="contentToggleContainer"
onClick={[MockFunction]}
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const OrderRow = props => {
className={classes.contentToggleContainer}
onClick={handleContentToggle}
type="button"
aria-expanded={isOpen}
>
{contentToggleIcon}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`renders correctly 1`] = `
aria-busy="false"
>
<button
aria-label="Sort Button Collapsed"
disabled={false}
onClick={[Function]}
onDragStart={[Function]}
Expand Down
17 changes: 17 additions & 0 deletions packages/venia-ui/lib/components/ProductSort/productSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ const ProductSort = props => {
setExpanded(!expanded);
};

const handleKeypress = e => {
if (e.code == 'Enter') {
setExpanded(expanded);
}
};
const result = expanded
? formatMessage({
id: 'productSort.sortButtonExpanded',
defaultMessage: 'Sort Button Expanded'
})
: formatMessage({
id: 'productSort.sortButtonCollapsed',
defaultMessage: 'Sort Button Collapsed'
});

return (
<div
ref={elementRef}
Expand All @@ -171,6 +186,8 @@ const ProductSort = props => {
}}
onClick={handleSortClick}
data-cy="ProductSort-sortButton"
onKeyDown={handleKeypress}
aria-label={result}
>
<span className={classes.mobileText}>
<FormattedMessage
Expand Down