Skip to content

Commit f2d8c40

Browse files
chore[actionbutton, actiongroup]: fix application of aria-labels (#3230)
* chore: aria-label only appears on icon-only button * chore: refactors action group to use different args - ensures that actiongroup arg types are used in some of the documentation template instead of actionbutton args - removes white space from stories file - corrects some sentence-case instances for story names * chore: fix context passing to template and indentation
1 parent 19477ac commit f2d8c40

File tree

4 files changed

+89
-154
lines changed

4 files changed

+89
-154
lines changed

components/actionbutton/stories/actionbutton.stories.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,22 @@ Default.args = {};
9999
Default.tags = ["!autodocs"];
100100

101101
// ********* DOCS ONLY ********* //
102-
103102
/**
104103
* Action buttons should always have a label, unless they are only using an icon that is universally understood and accessible. They can have an optional icon, but it should not be used for decoration. Use an icon only when necessary and when it has a strong association with the label text.
105104
*
106105
* The label can be hidden to create an icon-only action button. If the label is hidden, an icon is required, and the label will appear in a tooltip on hover.
107106
*/
108-
109107
export const Standard = TreatmentTemplate.bind({});
110108
Standard.args = Default.args;
111109
Standard.tags = ["!dev"];
112110
Standard.parameters = {
113111
chromatic: { disableSnapshot: true },
114112
};
115-
116113
Standard.storyName = "Default";
117114

118115
/**
119116
* The emphasized action button has a blue background for its selected state in order to provide a visual prominence. This is optimal for when the selection should call attention, such as within a tool bar.
120117
*/
121-
122118
export const Emphasized = TreatmentTemplate.bind({});
123119
Emphasized.tags = ["!dev"];
124120
Emphasized.args = {
@@ -133,7 +129,6 @@ Emphasized.parameters = {
133129
/**
134130
* Adding the `.spectrum-ActionButton--emphasized` class to a quiet action button can be effective in calling attention.
135131
*/
136-
137132
export const EmphasizedQuiet = TreatmentTemplate.bind({});
138133
EmphasizedQuiet.tags = ["!dev"];
139134
EmphasizedQuiet.args = {
@@ -150,7 +145,6 @@ EmphasizedQuiet.storyName = "Emphasized (quiet)";
150145
/**
151146
* Quiet action buttons have no visible background until they’re interacted with. This style works best when a clear layout (vertical stack, table, grid) makes it easy to parse the buttons. Too many quiet components in a small space can be hard to read.
152147
*/
153-
154148
export const Quiet = TreatmentTemplate.bind({});
155149
Quiet.tags = ["!dev"];
156150
Quiet.args = {
@@ -165,7 +159,6 @@ Quiet.parameters = {
165159
/**
166160
* An action button can have a hold icon (a small corner triangle). This icon indicates that holding down the action button for a short amount of time can reveal a popover menu, which can be used, for example, to switch between related actions. Because of the way padding is calculated, the hold icon must be placed before the workflow icon in the markup.
167161
*/
168-
169162
export const HoldIcon = IconOnlyOption.bind({});
170163
HoldIcon.tags = ["!dev"];
171164
HoldIcon.parameters = {
@@ -177,9 +170,7 @@ StaticWhiteDocs.tags = ["!dev"];
177170
StaticWhiteDocs.args = {
178171
staticColor: "white",
179172
};
180-
181173
StaticWhiteDocs.storyName = "Static white";
182-
183174
StaticWhiteDocs.parameters = {
184175
chromatic: { disableSnapshot: true },
185176
};
@@ -190,9 +181,7 @@ StaticWhiteQuiet.args = {
190181
staticColor: "white",
191182
isQuiet: true,
192183
};
193-
194184
StaticWhiteQuiet.storyName = "Static white (quiet)";
195-
196185
StaticWhiteQuiet.parameters = {
197186
chromatic: { disableSnapshot: true }
198187
};
@@ -203,7 +192,6 @@ StaticBlackDocs.args = {
203192
staticColor: "black",
204193
};
205194
StaticBlackDocs.storyName = "Static black";
206-
207195
StaticBlackDocs.parameters = {
208196
chromatic: { disableSnapshot: true },
209197
};
@@ -214,17 +202,14 @@ StaticBlackQuiet.args = {
214202
staticColor: "black",
215203
isQuiet: true,
216204
};
217-
218205
StaticBlackQuiet.storyName = "Static black (quiet)";
219-
220206
StaticBlackQuiet.parameters = {
221207
chromatic: { disableSnapshot: true }
222208
};
223209

224210
/**
225211
* Action buttons come in five different sizes: extra-small, small, medium, large, and extra-large. The medium size is the default and most frequently used option. Use the other sizes sparingly; they should be used to create a hierarchy of importance within the page.
226212
*/
227-
228213
export const Sizing = (args, context) => Sizes({
229214
Template: ActionButtonsWithIconOptions,
230215
withHeading: false,
@@ -237,7 +222,6 @@ Sizing.parameters = {
237222
chromatic: { disableSnapshot: true },
238223
};
239224

240-
241225
// ********* VRT ONLY ********* //
242226
export const WithForcedColors = ActionButtonGroup.bind({});
243227
WithForcedColors.args = Default.args;

components/actionbutton/stories/template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const Template = ({
6969
const { updateArgs } = context;
7070
return html`
7171
<button
72-
aria-label=${ifDefined(label)}
72+
aria-label=${ifDefined(hideLabel ? label : undefined)}
7373
aria-haspopup=${ifDefined(hasPopup && hasPopup !== "false" ? hasPopup : undefined)}
7474
aria-controls=${hasPopup && hasPopup !== "false" ? popupId : undefined}
7575
aria-pressed=${isSelected ? "true" : "false"}

components/actiongroup/stories/actiongroup.stories.js

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default {
4848
control: "boolean",
4949
},
5050
iconOnly: {
51-
name: "Icon Only",
51+
name: "Icon-only",
5252
type: { name: "boolean" },
5353
table: {
5454
type: { summary: "boolean" },
@@ -103,17 +103,14 @@ Default.tags = ["!autodocs"];
103103
Default.args = {};
104104

105105
// ********* DOCS ONLY ********* //
106-
107106
/**
108107
* An action group in a disabled state shows that the action buttons within the group exist, but are not available in that circumstance. This state can be used to maintain layout continuity and to communicate that an action group may become available later.
109108
*/
110-
111109
export const Disabled = ActionGroups.bind({});
112110
Disabled.tags = ["!dev"];
113111
Disabled.args = {
114112
areDisabled: true
115113
};
116-
117114
Disabled.parameters = {
118115
chromatic: { disableSnapshot: true },
119116
};
@@ -126,19 +123,16 @@ Emphasized.tags = ["!dev"];
126123
Emphasized.args = {
127124
areEmphasized: true
128125
};
129-
130126
Emphasized.parameters = {
131127
chromatic: { disableSnapshot: true },
132128
};
133129

134130
export const Horizontal = TreatmentTemplate.bind({});
135131
Horizontal.tags = ["!dev"];
136132
Horizontal.args = {};
137-
138133
Horizontal.parameters = {
139134
chromatic: { disableSnapshot: true },
140135
};
141-
142136
Horizontal.storyName = "Default";
143137

144138
/**
@@ -149,37 +143,33 @@ HorizontalCompact.tags = ["!dev"];
149143
HorizontalCompact.args = {
150144
compact: true
151145
};
152-
153146
HorizontalCompact.parameters = {
154147
chromatic: { disableSnapshot: true },
155148
};
149+
HorizontalCompact.storyName = "Horizontal compact";
156150

157151
/**
158152
* The vertical option should be reserved for when horizontal space is limited.
159153
*/
160-
161154
export const Vertical = TreatmentTemplate.bind({});
162155
Vertical.tags = ["!dev"];
163156
Vertical.args = {
164157
vertical: true
165158
};
166-
167159
Vertical.parameters = {
168160
chromatic: { disableSnapshot: true },
169161
};
170162

171-
172163
export const VerticalCompact = TreatmentTemplate.bind({});
173164
VerticalCompact.tags = ["!dev"];
174165
VerticalCompact.args = {
175166
compact: true,
176167
vertical: true
177168
};
178-
179169
VerticalCompact.parameters = {
180170
chromatic: { disableSnapshot: true },
181171
};
182-
172+
VerticalCompact.storyName = "Vertical compact";
183173

184174
export const HorizontalSizing = (args, context) => Sizes({
185175
Template: ActionGroups,
@@ -192,6 +182,7 @@ HorizontalSizing.tags = ["!dev"];
192182
HorizontalSizing.parameters = {
193183
chromatic: { disableSnapshot: true },
194184
};
185+
HorizontalSizing.storyName = "Horizontal sizing";
195186

196187
export const VerticalSizing = (args, context) => Sizes({
197188
Template: ActionGroups,
@@ -206,11 +197,11 @@ VerticalSizing.tags = ["!dev"];
206197
VerticalSizing.parameters = {
207198
chromatic: { disableSnapshot: true },
208199
};
200+
VerticalSizing.storyName = "Vertical sizing";
209201

210202
/**
211203
* When an action group is justified, it takes up the entire available container width, divided equally for each action button that is inside the group.
212204
*/
213-
214205
export const Justified = ActionGroups.bind({});
215206
Justified.tags = ["!dev"];
216207
Justified.args = {
@@ -219,15 +210,14 @@ Justified.args = {
219210
content: [
220211
{
221212
iconName: "AlignTop",
222-
label: "Align Top",
213+
label: "Align top",
223214
},
224215
{
225216
iconName: "AlignBottom",
226-
label: "Align Bottom",
217+
label: "Align bottom",
227218
},
228219
]
229220
};
230-
231221
Justified.parameters = {
232222
chromatic: { disableSnapshot: true },
233223
};
@@ -237,24 +227,23 @@ JustifiedIconOnly.tags = ["!dev"];
237227
JustifiedIconOnly.args = {
238228
customStyles: {"width": "300px"},
239229
justified: true,
230+
iconOnly: true,
240231
content: [
241232
{
242233
iconName: "AlignTop",
243-
label: "",
234+
label: "Align top",
244235
},
245236
{
246237
iconName: "AlignBottom",
247-
label: "",
238+
label: "Align bottom",
248239
},
249240
{
250241
iconName: "AlignMiddle",
251-
label: "",
242+
label: "Align middle",
252243
},
253244
]
254245
};
255-
256246
JustifiedIconOnly.storyName = "Justified (icon-only)";
257-
258247
JustifiedIconOnly.parameters = {
259248
chromatic: { disableSnapshot: true },
260249
};
@@ -265,40 +254,36 @@ JustifiedIconOnlyCompact.args = {
265254
customStyles: {"width": "300px"},
266255
justified: true,
267256
compact: true,
257+
iconOnly: true,
268258
content: [
269259
{
270260
iconName: "AlignTop",
271-
label: "",
261+
label: "Align top",
272262
},
273263
{
274264
iconName: "AlignBottom",
275-
label: "",
265+
label: "Align bottom",
276266
},
277267
{
278268
iconName: "AlignMiddle",
279-
label: "",
269+
label: "Align middle",
280270
},
281271
]
282272
};
283-
284273
JustifiedIconOnlyCompact.storyName = "Justified (compact, icon-only)";
285-
286274
JustifiedIconOnlyCompact.parameters = {
287275
chromatic: { disableSnapshot: true },
288276
};
289277

290-
291278
/**
292279
* When space is limited in an action group, there are 2 options for the group's overflow behavior: wrap or collapse. By default, an action group is set to wrap, meaning that the action buttons inside the group wrap to form another line. Alternatively, an action group can be set to collapse inside a **More (...)** action button.
293280
*/
294281
export const Overflow = OverflowOption.bind({});
295282
Overflow.tags = ["!dev"];
296-
297283
Overflow.parameters = {
298284
chromatic: { disableSnapshot: true },
299285
};
300286

301-
302287
// ********* VRT ONLY ********* //
303288
export const WithForcedColors = ActionGroups.bind({});
304289
WithForcedColors.args = Default.args;

0 commit comments

Comments
 (0)