Skip to content

Commit 36e7d79

Browse files
authored
chore(panels): backport #4654 to 232-summer-21 (#4667)
1 parent ac59b10 commit 36e7d79

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

ui/components/menus/docs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ For an overflow of action items, use the overflow menu with actions styling by a
281281

282282
<Example title="Menu with Action Overflow">
283283
<CodeView demoStyles="height: 150px;">
284-
<ActionOverflow />
284+
<ActionOverflow isOpen />
285285
</CodeView>
286286
</Example>
287287

ui/components/menus/dropdown/example.jsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,28 +311,32 @@ export const IconRight = props => (
311311
</Trigger>
312312
);
313313

314-
export const ActionOverflow = ({ size, position }) => {
315-
const positionClassNames = classNames({
316-
'slds-dropdown_left': position === 'left',
317-
'slds-dropdown_right': position === 'right',
318-
'slds-dropdown_bottom': position === 'bottom'
319-
});
314+
export const ActionOverflow = ({ isOpen, size, position }) => {
315+
const menuClassNames = classNames(
316+
{
317+
'slds-dropdown_left': position === 'left',
318+
'slds-dropdown_right': position === 'right',
319+
'slds-dropdown_bottom': position === 'bottom'
320+
},
321+
'slds-dropdown_actions'
322+
);
320323

321324
return (
322325
<Trigger
323-
isOpen
326+
isOpen={isOpen}
324327
triggerIcon={
325328
<ButtonIcon
326329
className="slds-button_icon-border-filled"
327330
symbol="down"
328331
assistiveText="Show More"
329332
aria-haspopup="true"
333+
aria-expanded={isOpen ? 'true' : 'false'}
330334
title="Show More"
331335
size={size}
332336
/>
333337
}
334338
>
335-
<Menu className={classNames(positionClassNames, 'slds-dropdown_actions')}>
339+
<Menu className={menuClassNames}>
336340
<MenuList ariaLabel="Show More">
337341
<MenuItem tabIndex="0">Action One</MenuItem>
338342
<MenuItem>Action Two</MenuItem>
@@ -344,6 +348,7 @@ export const ActionOverflow = ({ size, position }) => {
344348
};
345349

346350
ActionOverflow.propTypes = {
351+
isOpen: PropTypes.bool,
347352
position: PropTypes.string,
348353
size: PropTypes.string
349354
};
@@ -484,7 +489,7 @@ export let examples = [
484489
{
485490
id: 'action-overflow',
486491
label: 'Overflow menu with actions',
487-
element: <ActionOverflow />
492+
element: <ActionOverflow isOpen />
488493
},
489494
{
490495
id: 'notifications-menu',

ui/components/panels/__tests__/__snapshots__/snapshot.spec.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ exports[`render Panel component renders Base Panel with secondary actions 1`] =
729729
className="slds-dropdown-trigger slds-dropdown-trigger_click slds-is-open"
730730
>
731731
<button
732+
aria-expanded="true"
732733
aria-haspopup="true"
733734
className="slds-button slds-button_icon slds-button_icon-small slds-button_icon-border-filled"
734735
onClick={[Function]}

ui/components/panels/base/example.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export let examples = [
3636
title="Panel Header"
3737
docked="left"
3838
invoke="toggle"
39-
headerActions={<ActionOverflow size="small" position="right" />}
39+
headerActions={<ActionOverflow position="right" size="small" isOpen />}
4040
>
4141
A panel body accepts any layout or component
4242
</Panel>
@@ -62,7 +62,7 @@ export let examples = [
6262
title="Panel Header"
6363
docked="left"
6464
invoke="drill-in"
65-
headerActions={<ActionOverflow size="small" position="right" />}
65+
headerActions={<ActionOverflow size="small" position="right" isOpen />}
6666
>
6767
A panel body accepts any layout or component
6868
</Panel>

ui/components/panels/docs.mdx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ The panel should take up 100% of the height of its parent container. In most cas
5151
</p>
5252
</Blockquote>
5353

54+
### Accessibility
55+
56+
When managing the visibility of the panel, there are a few essential accessibility elements to make sure are in place:
57+
58+
- When the panel is not visible, set its `aria-hidden` attribute to `true`, and when visible, set `aria-hidden` to `false`.
59+
- If the panel's visibility is triggered by an element, the triggering element must be focusable with `aria-controls` set to the unique ID of the panel and `aria-expanded` set to either `true` or `false` depending on the visibility of the panel.
60+
- When toggling a panel open, place the user's focus inside the first focusable element within the panel that isn't the close button. If the close button is the only focusable element, place focus there. Return focus to the triggering element when the panel closes.
61+
5462
## Base
5563

5664
<Example title="Panel base">
@@ -114,6 +122,12 @@ To center the header title, add the class `slds-panel__header_align-center` to t
114122

115123
Secondary actions provide a compact way to offer additional actions without the need for a dedicated action toolbar. Actions in the menu apply to the entire component.
116124

125+
<Blockquote type="a11y" header="Accessibility Requirement">
126+
<p>
127+
Secondary actions use the <a href="/components/menus/#Accessibility">menu component</a>. All of the <a href="/components/menus/#Accessibility">accessibility guidelines</a> for the menu component are pertinent within the context of secondary actions.
128+
</p>
129+
</Blockquote>
130+
117131
<CodeView
118132
demoStyles={getDemoStylesById(Base.examples, 'with-secondary-actions')}
119133
>
@@ -244,7 +258,7 @@ Filtering lists or reports can be done by using a Filtering expressions inside o
244258
Make sure to use assistive text to improve the clarity of what you might be
245259
editing, for example, add{' '}
246260
<code>
247-
<span className="slds-assistive-text">Edit filter:</span>
261+
&lt;span className="slds-assistive-text"&gt;Edit filter:&lt;/span&gt;
248262
</code>{' '}
249263
to the button element inside each filterable object.
250264
</p>

0 commit comments

Comments
 (0)