Skip to content

Commit

Permalink
Merge pull request #96 from Cognigy/feature/adaptive-card-heading-a11y
Browse files Browse the repository at this point in the history
Feature/adaptive card heading a11y
  • Loading branch information
sushmi21 authored Sep 30, 2024
2 parents 1f094c1 + 21dd725 commit 2050457
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/messages/AdaptiveCards/components/Adaptivecard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ const AdaptiveCard: FC<IAdaptiveCardProps> = props => {
if (result) {
targetRef.current.innerHTML = "";
targetRef.current.appendChild(result);
// Add aria-level attribute to heading elements
const headings = targetRef.current.querySelectorAll("[role='heading']");
headings.forEach(heading => {
if (heading.getAttribute("aria-level") === null)
heading.setAttribute("aria-level", "2");
});
}
} catch (error) {
console.error("Unable to render Adaptive Card: ", error);
Expand Down
2 changes: 1 addition & 1 deletion src/messages/Video/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const Video: FC = () => {
kind: "subtitles",
src: captionsUrl as string,
srcLang: "en-US", // TODO: Get language from Say node in the future
label: "English",
label: "On",
},
],
};
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/adaptiveCards.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "I eat only ><_>"
"text": "I eat only ><_>",
"style": "heading"
},
{
"type": "ColumnSet",
Expand Down Expand Up @@ -116,7 +117,8 @@
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "Large header"
"text": "Large header",
"style": "heading"
},
{
"type": "Input.Text",
Expand Down

0 comments on commit 2050457

Please sign in to comment.