Skip to content

Commit

Permalink
Fix Adaptive Cards TextBlock element missing aria-level (#4329)
Browse files Browse the repository at this point in the history
* Add ACHostConfig.textBlock.headingLevel

* Add entry
  • Loading branch information
compulim authored Jun 28, 2022
1 parent d972175 commit 9428638
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixes [#4294](https://github.com/microsoft/BotFramework-WebChat/issues/4294). Screen reader should not read message twice when navigating in the chat history, by [@compulim](https://github.com/compulim), in PR [#4323](https://github.com/microsoft/BotFramework-WebChat/issues/4323)
- Fixes [#4295](https://github.com/microsoft/BotFramework-WebChat/issues/4295). Screen reader should not read suggested actions twice when message arrive in live region, by [@compulim](https://github.com/compulim), in PR [#4323](https://github.com/microsoft/BotFramework-WebChat/issues/4323)
- Fixes [#4325](https://github.com/microsoft/BotFramework-WebChat/issues/4325). `aria-keyshortcuts` should use modifier keys according to `KeyboardEvent` key values spec, by [@compulim](https://github.com/compulim), in PR [#4323](https://github.com/microsoft/BotFramework-WebChat/issues/4323)
- Fixes [#4327](https://github.com/microsoft/BotFramework-WebChat/issues/4327). In Adaptive Cards, `TextBlock` with `style="heading"` should have `aria-level` set, by [@compulim](https://github.com/compulim), in PR [#4329](https://github.com/microsoft/BotFramework-WebChat/issues/4329)

## [4.15.2] - 2022-05-09

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

audioElement.removeAttribute('controls');

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

audioElement.removeAttribute('controls');

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

videoElement.removeAttribute('controls');

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

videoElement.removeAttribute('controls');

await pageObjects.verifyDOMIntegrity();
await pageObjects.focusSendBoxTextBox();

await host.sendShiftTab(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export default function createAdaptiveCardsHostConfig(styleOptions: FullBundleSt
wrap: true
},
spacing: 8
},
textBlock: {
headingLevel: 1
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
export default function verifyDOMIntegrity() {
// If an element has "aria-labelledby", the label element must be present on the screen.
[].forEach.call(document.querySelectorAll('[aria-labelledby]'), element => {
const labelId = element.getAttribute('aria-labelledby');
const labelElement = document.getElementById(labelId);

if (!labelElement) {
const message = `verifyDOMIntegrity: Cannot find element referenced by aria-labelledby attribute with ID "${labelId}".`;

console.warn(message, element);

throw new Error(message);
}
element
.getAttribute('aria-labelledby')
.split(' ')
.map(labelId => labelId.trim())
.filter(Boolean)
.forEach(labelId => {
const labelElement = document.getElementById(labelId);

if (!labelElement) {
const message = `verifyDOMIntegrity: Cannot find element referenced by aria-labelledby attribute with ID "${labelId}".`;

console.warn(message, element);

throw new Error(message);
}
});
});

// No two elements can have the same ID.
Expand Down Expand Up @@ -41,4 +47,17 @@ export default function verifyDOMIntegrity() {
throw new Error(message);
}
});

// Elements of `role="heading"` must have `aria-level` set
[].forEach.call(document.querySelectorAll('[role="heading"]'), element => {
const ariaLevel = +element.getAttribute('aria-level');

if (!(ariaLevel >= 1 && ariaLevel === ~~ariaLevel)) {
const message = 'Elements of role="heading" must have aria-level set to an integer equal to or greater than 1.';

console.warn(message, element);

throw new Error(message);
}
});
}

0 comments on commit 9428638

Please sign in to comment.