Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Legends:

## [Unreleased]

### Added

- Added `styleOptions.richCardTitleOmitHeadingRole` (default `false`) to opt out of `style: 'heading'` on rich card titles, in PR [#5839](https://github.com/microsoft/BotFramework-WebChat/pull/5839), by [@cjennison](https://github.com/cjennison)


## [4.19.1] - 2026-06-09

### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[role='heading'] {
background-color: yellow !important;
outline: dashed 2px Red !important;
}
16 changes: 13 additions & 3 deletions __tests__/html2/accessibility/attachment/heroCard.heading.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<link href="heading-indicator.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
Expand All @@ -21,12 +22,21 @@

await pageObjects.sendMessageViaSendBox('herocard', { waitForSend: true });
await pageConditions.minNumActivitiesShown(2);
await pageConditions.allImagesLoaded();
await pageConditions.scrollToBottomCompleted();

expect(document.querySelector('.ac-textBlock[role="heading"]')).toHaveProperty(
'innerText',
'\u200BDetails about image 1\u200B'
const heroCardActivity = Array.from(webChatElement.querySelectorAll('.webchat__basic-transcript__activity')).find(
(activity) => !!activity.querySelector('.ac-textBlock')
);
expect(heroCardActivity).toBeTruthy();

const titleTextBlock = Array.from(heroCardActivity.querySelectorAll('.ac-textBlock')).find(
(block) => block.innerText === '\u200BDetails about image 1\u200B'
);
expect(titleTextBlock).toBeTruthy();
expect(titleTextBlock.getAttribute('role')).toBe('heading');

await host.snapshot('local');
});
</script>
</body>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<link href="heading-indicator.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
const store = testHelpers.createStore();
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
const styleOptions = { richCardTitleOmitHeadingRole: true };
const baseProps = { directLine, store, styleOptions };
const webChatElement = document.getElementById('webchat');

WebChat.renderWebChat(baseProps, webChatElement);

await pageConditions.uiConnected();

await pageObjects.sendMessageViaSendBox('herocard', { waitForSend: true });
await pageConditions.minNumActivitiesShown(2);
await pageConditions.allImagesLoaded();
await pageConditions.scrollToBottomCompleted();

const heroCardActivity = Array.from(webChatElement.querySelectorAll('.webchat__basic-transcript__activity')).find(
(activity) => !!activity.querySelector('.ac-textBlock')
);
expect(heroCardActivity).toBeTruthy();

const titleTextBlock = Array.from(heroCardActivity.querySelectorAll('.ac-textBlock')).find(
(block) => block.innerText === '\u200BDetails about image 1\u200B'
);
expect(titleTextBlock).toBeTruthy();

expect(titleTextBlock.getAttribute('role')).toBe(null);
expect(heroCardActivity.querySelector('.ac-textBlock[role="heading"]')).toBe(null);
Comment thread
OEvgeny marked this conversation as resolved.

await host.snapshot('local');
});
</script>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ type StrictAdaptiveCardsStyleOptions = {
* Enable title (and subtitle) wrapping
*/
richCardWrapTitle: boolean | undefined;

/**
* Cards: Rich Cards
* When `true`, omits `style: 'heading'` from the title so the rendered TextBlock has no
* `role="heading"` / `aria-level`. Defaults to `false` (existing behavior keeps the heading
* style; see issue #4327).
*/
richCardTitleOmitHeadingRole: boolean | undefined;
};

type AdaptiveCardsStyleOptions = Partial<StrictAdaptiveCardsStyleOptions>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ export default class AdaptiveCardBuilder {
}

addCommonHeaders(content: ICommonContent) {
const { richCardWrapTitle } = this.styleOptions;
const { richCardTitleOmitHeadingRole, richCardWrapTitle } = this.styleOptions;
this.addTextBlock(content.title, {
...(richCardTitleOmitHeadingRole ? {} : { style: 'heading' }),
color: TextColor.Default,
size: TextSize.Medium,
style: 'heading',
weight: TextWeight.Bolder,
wrap: richCardWrapTitle
});
Expand Down
1 change: 1 addition & 0 deletions packages/bundle/src/adaptiveCards/defaultStyleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const ADAPTIVE_CARDS_DEFAULT_STYLE_OPTIONS: Required<AdaptiveCardsStyleOptions>
cardEmphasisBackgroundColor: '#F9F9F9',
cardPushButtonBackgroundColor: '#0063B1',
cardPushButtonTextColor: 'White',
richCardTitleOmitHeadingRole: false,
richCardWrapTitle: false
};

Expand Down
Loading