From adaaeb653a37c0eec6ce5fbc57b73c24ca09f347 Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Thu, 6 Jul 2023 12:50:43 -0700 Subject: [PATCH 1/6] fix: toolbar should not throw if start/end slots do not exist (#6770) * fix: toolbar should not throw if start or end is undefined * Change files --- ...-foundation-240d2dac-2fd1-4e5f-a760-03c9e5505330.json | 7 +++++++ .../fast-foundation/src/toolbar/toolbar.ts | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 change/@microsoft-fast-foundation-240d2dac-2fd1-4e5f-a760-03c9e5505330.json diff --git a/change/@microsoft-fast-foundation-240d2dac-2fd1-4e5f-a760-03c9e5505330.json b/change/@microsoft-fast-foundation-240d2dac-2fd1-4e5f-a760-03c9e5505330.json new file mode 100644 index 00000000000..481bbe6e631 --- /dev/null +++ b/change/@microsoft-fast-foundation-240d2dac-2fd1-4e5f-a760-03c9e5505330.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "fix: toolbar should not throw if start or end is undefined", + "packageName": "@microsoft/fast-foundation", + "email": "chhol@microsoft.com", + "dependentChangeType": "prerelease" +} diff --git a/packages/web-components/fast-foundation/src/toolbar/toolbar.ts b/packages/web-components/fast-foundation/src/toolbar/toolbar.ts index ce6466ff2de..6701e26cd89 100644 --- a/packages/web-components/fast-foundation/src/toolbar/toolbar.ts +++ b/packages/web-components/fast-foundation/src/toolbar/toolbar.ts @@ -207,11 +207,10 @@ export class FASTToolbar extends FASTElement { * @internal */ protected get allSlottedItems(): (HTMLElement | Node)[] { - return [ - ...this.start.assignedElements(), - ...this.slottedItems, - ...this.end.assignedElements(), - ]; + const start = this.start?.assignedElements() ?? []; + const end = this.end?.assignedElements() ?? []; + + return [...start, ...this.slottedItems, ...end]; } /** From b5f23eb6c537a2659da4666f3c993c360d523153 Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Mon, 17 Jul 2023 15:00:26 -0700 Subject: [PATCH 2/6] fix: only add aria orientation for proper role divider (#6771) * fix: add aria-orientation to divider only when role equals separator * Change files * pass role in test * pri exclusion in template logic --- ...-c935a253-e2ce-42db-a6fd-50b3adbd8839.json | 7 +++++ .../src/divider/divider.pw.spec.ts | 26 +++++++++++++++++++ .../src/divider/divider.template.ts | 7 ++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 change/@microsoft-fast-foundation-c935a253-e2ce-42db-a6fd-50b3adbd8839.json diff --git a/change/@microsoft-fast-foundation-c935a253-e2ce-42db-a6fd-50b3adbd8839.json b/change/@microsoft-fast-foundation-c935a253-e2ce-42db-a6fd-50b3adbd8839.json new file mode 100644 index 00000000000..fe8d1eeef35 --- /dev/null +++ b/change/@microsoft-fast-foundation-c935a253-e2ce-42db-a6fd-50b3adbd8839.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "fix: add aria-orientation to divider only when role equals separator", + "packageName": "@microsoft/fast-foundation", + "email": "chhol@microsoft.com", + "dependentChangeType": "prerelease" +} diff --git a/packages/web-components/fast-foundation/src/divider/divider.pw.spec.ts b/packages/web-components/fast-foundation/src/divider/divider.pw.spec.ts index 8e6369a92df..a90f998758c 100644 --- a/packages/web-components/fast-foundation/src/divider/divider.pw.spec.ts +++ b/packages/web-components/fast-foundation/src/divider/divider.pw.spec.ts @@ -70,4 +70,30 @@ test.describe("Divider", () => { DividerOrientation.horizontal ); }); + + test("should NOT set the `aria-orientation` attribute equal to the `orientation` value if the `role` is presentational", async () => { + await root.evaluate(node => { + node.innerHTML = /* html */ ` + + `; + }); + + await expect(element).toHaveAttribute( + "aria-orientation", + DividerOrientation.vertical + ); + + await element.evaluate((node: FASTDivider, DividerRole) => { + node.role = DividerRole.presentation; + }, DividerRole); + + await expect(element).not.toHaveAttribute( + "aria-orientation", + DividerOrientation.horizontal + ); + await expect(element).not.toHaveAttribute( + "aria-orientation", + DividerOrientation.vertical + ); + }); }); diff --git a/packages/web-components/fast-foundation/src/divider/divider.template.ts b/packages/web-components/fast-foundation/src/divider/divider.template.ts index 3ef55e26f51..e7d54def8cb 100644 --- a/packages/web-components/fast-foundation/src/divider/divider.template.ts +++ b/packages/web-components/fast-foundation/src/divider/divider.template.ts @@ -1,5 +1,6 @@ import { ElementViewTemplate, html } from "@microsoft/fast-element"; import type { FASTDivider } from "./divider.js"; +import { DividerRole } from "./divider.options.js"; /** * The template for the {@link @microsoft/fast-foundation#FASTDivider} component. @@ -7,7 +8,11 @@ import type { FASTDivider } from "./divider.js"; */ export function dividerTemplate(): ElementViewTemplate { return html` -