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
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, in PR [#5839](https://github.com/microsoft/BotFramework-WebChat/pull/5839), by [@cjennison](https://github.com/cjennison)

### 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
15 changes: 12 additions & 3 deletions __tests__/html2/accessibility/attachment/heroCard.heading.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,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,45 @@
<!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.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);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: add both test one with visible styling for [role="heading"], and this one. Add snapshots for both so the change can be visually inspected.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea — added host.snapshot('local') to both heroCard.noHeading.html and heroCard.heading.html, and brought the heading test up to the same scoped-query pattern (locate the hero card activity, then match the title text block by its expected text and assert role='heading'). Both tests now also wait for allImagesLoaded so the captured snapshots are stable. Fixed in 74295fc.


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,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