Skip to content

Commit 6e51044

Browse files
Mnickiimusale
andauthored
fix(a11y): announce expanded/collapsed state of options menu in mgt-planner (#3186)
* announce expanded/collapsed state of options menu * fix menu item hover * fix narration --------- Co-authored-by: Musale Martin <[email protected]>
1 parent 7f9eac3 commit 6e51044

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed

packages/mgt-components/src/components/sub-components/mgt-dot-options/mgt-dot-options.scss

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@import '../../../styles/shared-styles';
99
@import '../../../styles/shared-sass-variables';
1010
@import '../../../../../../node_modules/office-ui-fabric-core/dist/sass/References';
11+
@import './mgt-dot-options.theme';
1112

1213
$dot-options-translatey: var(--dot-options-translatey, translateY(32px));
1314

@@ -26,8 +27,8 @@ $dot-options-translatey: var(--dot-options-translatey, translateY(32px));
2627

2728
.menu {
2829
position: absolute;
29-
box-shadow: var(--neutral-fill-rest) 0 0 40px 5px;
30-
background: var(--neutral-fill-rest);
30+
box-shadow: $dot-options-menu-shadow-color 0 0 40px 5px;
31+
background: $dot-options-menu-background-color;
3132
z-index: 1;
3233
display: none;
3334
white-space: nowrap;
@@ -43,4 +44,14 @@ $dot-options-translatey: var(--dot-options-translatey, translateY(32px));
4344
background: inherit;
4445
}
4546
}
47+
48+
fluent-menu > fluent-menu-item {
49+
&::part(content) {
50+
color: $dot-options-menu-item-color;
51+
}
52+
53+
&:hover {
54+
background: $dot-options-menu-item-hover-background-color;
55+
}
56+
}
4657
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* -------------------------------------------------------------------------------------------
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4+
* See License in the project root for license information.
5+
* -------------------------------------------------------------------------------------------
6+
*/
7+
8+
@import '../../../styles/shared-styles';
9+
10+
$dot-options-menu-background-color: var(--dot-options-menu-background-color, var(--fill-color));
11+
$dot-options-menu-shadow-color: var(--dot-options-menu-shadow-color, var(--fill-color));
12+
$dot-options-menu-item-color: var(--dot-options-menu-item-color, var(--neutral-foreground-hint));
13+
$dot-options-menu-item-hover-background-color: var(
14+
--dot-options-menu-item-hover-background-color,
15+
var(--neutral-fill-input-hover)
16+
);

packages/mgt-components/src/components/sub-components/mgt-dot-options/mgt-dot-options.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export const registerMgtDotOptionsComponent = () => {
3232
* @export MgtDotOptions
3333
* @class MgtDotOptions
3434
* @extends {MgtBaseComponent}
35+
*
36+
* @cssprop --dot-options-menu-background-color - {Color} The color of the background of the menu.
37+
* @cssprop --dot-options-menu-shadow-color - {Color} The color of the shadow of the menu.
38+
* @cssprop --dot-options-menu-item-color - {Color} The color of the menu items.
39+
* @cssprop --dot-options-menu-item-hover-background-color - {Color} The color of the menu items when hovered.
3540
*/
3641

3742
export class MgtDotOptions extends MgtBaseTaskComponent {
@@ -90,10 +95,11 @@ export class MgtDotOptions extends MgtBaseTaskComponent {
9095
<fluent-button
9196
appearance="stealth"
9297
aria-label=${this.strings.dotOptionsTitle}
98+
aria-expanded=${this.open}
9399
@click=${this.onDotClick}
94100
@keydown=${this.onDotKeydown}
95101
class="dot-icon">${getSvg(SvgIcon.Dot)}</fluent-button>
96-
<fluent-menu class=${classMap({ menu: true, open: this.open })}>
102+
<fluent-menu class=${classMap({ menu: true, open: this.open })} aria-expanded=${this.open} aria-label=${this.strings.dotOptionsTitle}>
97103
${menuOptions.map(opt => this.getMenuOption(opt, this.options[opt]))}
98104
</fluent-menu>`;
99105
};

packages/mgt-components/src/utils/SvgHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export const getSvg = (svgIcon: SvgIcon, color?: string) => {
470470
case SvgIcon.Dot:
471471
return html`
472472
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
473-
<path d="M6.25 10C6.25 10.6904 5.69036 11.25 5 11.25C4.30964 11.25 3.75 10.6904 3.75 10C3.75 9.30964 4.30964 8.75 5 8.75C5.69036 8.75 6.25 9.30964 6.25 10ZM11.25 10C11.25 10.6904 10.6904 11.25 10 11.25C9.30964 11.25 8.75 10.6904 8.75 10C8.75 9.30964 9.30964 8.75 10 8.75C10.6904 8.75 11.25 9.30964 11.25 10ZM15 11.25C15.6904 11.25 16.25 10.6904 16.25 10C16.25 9.30964 15.6904 8.75 15 8.75C14.3096 8.75 13.75 9.30964 13.75 10C13.75 10.6904 14.3096 11.25 15 11.25Z" fill="#242424"/>
473+
<path d="M6.25 10C6.25 10.6904 5.69036 11.25 5 11.25C4.30964 11.25 3.75 10.6904 3.75 10C3.75 9.30964 4.30964 8.75 5 8.75C5.69036 8.75 6.25 9.30964 6.25 10ZM11.25 10C11.25 10.6904 10.6904 11.25 10 11.25C9.30964 11.25 8.75 10.6904 8.75 10C8.75 9.30964 9.30964 8.75 10 8.75C10.6904 8.75 11.25 9.30964 11.25 10ZM15 11.25C15.6904 11.25 16.25 10.6904 16.25 10C16.25 9.30964 15.6904 8.75 15 8.75C14.3096 8.75 13.75 9.30964 13.75 10C13.75 10.6904 14.3096 11.25 15 11.25Z" fill="currentColor"/>
474474
</svg>
475475
`;
476476

stories/components/planner/planner.style.stories.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ export const customCSSProperties = () => html`
102102
103103
--task-new-person-icon-text-color: blue;
104104
--task-new-person-icon-color: blue;
105+
106+
/** affects the options menu */
107+
--dot-options-menu-background-color: yellow;
108+
--dot-options-menu-shadow-color: yellow;
109+
--dot-options-menu-item-color: maroon;
110+
--dot-options-menu-item-hover-background-color: white;
105111
}
106112
</style>
107113
<mgt-planner class="tasks"></mgt-planner>

0 commit comments

Comments
 (0)