Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Legends:

## [Unreleased]

### Added

- Added `styleOptions.richCardTitleAsHeading` (default `true`) to opt out of `style: 'heading'` on rich card titles, by [@cjennison](https://github.com/cjennison). Resolves the conflict with [#4327](https://github.com/microsoft/BotFramework-WebChat/issues/4327) for hosts where card titles are not navigational headings.
Comment thread
cjennison marked this conversation as resolved.
Outdated

### Changed

- Removed `markdown-it` and completed migration to `micromark`, in PR [#5825](https://github.com/microsoft/BotFramework-WebChat/pull/5825), by [@compulim](https://github.com/compulim)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<link href="/assets/index.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 = { richCardTitleAsHeading: false };
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.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.
});
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ type StrictAdaptiveCardsStyleOptions = {
* Enable title (and subtitle) wrapping
*/
richCardWrapTitle: boolean | undefined;

/**
* Cards: Rich Cards
* When `false`, omits `style: 'heading'` from the title so the rendered TextBlock has no
* `role="heading"` / `aria-level`. Defaults to `true`. See issue #4327.
*/
richCardTitleAsHeading: 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 { richCardTitleAsHeading, richCardWrapTitle } = this.styleOptions;
this.addTextBlock(content.title, {
color: TextColor.Default,
size: TextSize.Medium,
style: 'heading',
...(richCardTitleAsHeading === false ? {} : { 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',
richCardTitleAsHeading: true,
richCardWrapTitle: false
};

Expand Down
Loading