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-2492::Missing visual text label for buttons #3952

Merged
merged 14 commits into from
Nov 11, 2022
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 @@ -2,6 +2,7 @@

exports[`appends "_focused" to className if hasFocus is true 1`] = `
<button
aria-label="Color's option red"
className="root_focused"
onClick={[Function]}
style={
Expand Down Expand Up @@ -37,6 +38,7 @@ exports[`appends "_focused" to className if hasFocus is true 1`] = `

exports[`appends "_outOfStock" to className if isEverythingOutOfStock is true 1`] = `
<button
aria-label="Color's option red"
className="root_outOfStock"
disabled={true}
onClick={[Function]}
Expand Down Expand Up @@ -73,6 +75,7 @@ exports[`appends "_outOfStock" to className if isEverythingOutOfStock is true 1`

exports[`appends "_outOfStock" to className if isOptionOutOfStock is true 1`] = `
<button
aria-label="Color's option red"
className="root_outOfStock"
disabled={true}
onClick={[Function]}
Expand All @@ -88,6 +91,7 @@ exports[`appends "_outOfStock" to className if isOptionOutOfStock is true 1`] =

exports[`appends "_selected" to className if isSelected is true 1`] = `
<button
aria-label="Color's Selected option red"
className="root_selected"
onClick={[Function]}
style={
Expand Down Expand Up @@ -123,6 +127,7 @@ exports[`appends "_selected" to className if isSelected is true 1`] = `

exports[`renders a Swatch correctly 1`] = `
<button
aria-label="Color's option red"
className="root"
onClick={[Function]}
style={
Expand Down Expand Up @@ -158,6 +163,7 @@ exports[`renders a Swatch correctly 1`] = `

exports[`renders an icon if isSelected is true 1`] = `
<button
aria-label="Color's Selected option red"
className="root_selected"
onClick={[Function]}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`renders SwatchList component correctly 1`] = `
className="root"
>
<button
aria-label="undefined's option foo"
className="root"
onClick={[Function]}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const defaultProps = {
swatch_data: {
value: '#123123'
}
}
},
attributeLabel: 'Color'
};

test('renders a Swatch correctly', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/venia-ui/lib/components/ProductOptions/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const Option = props => {
onSelectionChange={handleSelectionChange}
isEverythingOutOfStock={isEverythingOutOfStock}
outOfStockVariants={outOfStockVariants}
attributeLabel={label}
/>
<dl className={classes.selection}>
<dt
Expand Down
7 changes: 5 additions & 2 deletions packages/venia-ui/lib/components/ProductOptions/swatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const Swatch = props => {
onClick,
style,
isEverythingOutOfStock,
isOptionOutOfStock
isOptionOutOfStock,
attributeLabel
} = props;

const talonProps = useSwatch({
Expand Down Expand Up @@ -83,7 +84,8 @@ const Swatch = props => {
'--venia-swatch-bg': swatchValue
});
}

const selectedText = isSelected ? 'Selected' : '';
const ariaLabel = `${attributeLabel}'s ${selectedText} option ${label}`;
const className =
classes[
getClassName(
Expand All @@ -104,6 +106,7 @@ const Swatch = props => {
type="button"
data-cy="Swatch-root"
disabled={isEverythingOutOfStock || isOptionOutOfStock}
aria-label={ariaLabel}
>
{!isOptionOutOfStock && (
<Icon classes={{ root: checkStyle }} src={CheckIcon} />
Expand Down
7 changes: 5 additions & 2 deletions packages/venia-ui/lib/components/ProductOptions/swatchList.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const SwatchList = props => {
items,
onSelectionChange,
isEverythingOutOfStock,
outOfStockVariants
outOfStockVariants,
attributeLabel
} = props;

const classes = useStyle(defaultClasses, props.classes);
Expand All @@ -35,6 +36,7 @@ const SwatchList = props => {
onClick={onSelectionChange}
isEverythingOutOfStock={isEverythingOutOfStock}
isOptionOutOfStock={isOptionOutOfStock}
attributeLabel={attributeLabel}
/>
);
}),
Expand All @@ -44,7 +46,8 @@ const SwatchList = props => {
items,
onSelectionChange,
isEverythingOutOfStock,
outOfStockVariants
outOfStockVariants,
attributeLabel
]
);

Expand Down