Skip to content

Commit 28b438b

Browse files
committed
Allow any role
1 parent 847e900 commit 28b438b

3 files changed

Lines changed: 45 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
142142
- Bundling vendor chunks, by [@compulim](https://github.com/compulim) in PR [#5595](https://github.com/microsoft/BotFramework-WebChat/pull/5595)
143143
- Added deprecation notes for legacy imports, by [@compulim](https://github.com/compulim) in PR [#5600](https://github.com/microsoft/BotFramework-WebChat/pull/5600)
144144
- `import { hooks } from 'botframework-webchat'` should be replaced by `import * as hooks from 'botframework-webchat/hook'`
145+
- Relaxed `role` prop to allow any string instead of ARIA landmark roles, in PR [#5561](https://github.com/microsoft/BotFramework-WebChat/pull/5561), by [@compulim](https://github.com/compulim)
145146

146147
### Changed
147148

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
5+
</head>
6+
<body>
7+
<main id="webchat"></main>
8+
<script type="importmap">
9+
{
10+
"imports": {
11+
"botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js",
12+
"react": "/__dist__/packages/bundle/static/react.baseline.js",
13+
"react-dom": "/__dist__/packages/bundle/static/react-dom.baseline.js"
14+
}
15+
}
16+
</script>
17+
<script type="module">
18+
import '/test-harness.mjs';
19+
import '/test-page-object.mjs';
20+
21+
import { createDirectLine, createStoreWithOptions, renderWebChat } from 'botframework-webchat';
22+
import { version } from 'react';
23+
24+
run(async function () {
25+
const {
26+
testHelpers: { createDirectLineEmulator }
27+
} = window;
28+
29+
// TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line.
30+
window.WebChat = { createStoreWithOptions };
31+
32+
const { directLine, store } = createDirectLineEmulator();
33+
34+
renderWebChat({ directLine, role: 'application', store }, document.getElementById('webchat'));
35+
36+
await pageConditions.uiConnected();
37+
38+
expect(document.querySelector('#webchat .webchat__surface').getAttribute('role')).toBe('application');
39+
});
40+
</script>
41+
</body>
42+
</html>

packages/component/src/BasicWebChat.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { validateProps } from '@msinternal/botframework-webchat-react-valibot';
55
import { SendBoxMiddlewareProxy, hooks } from 'botframework-webchat-api';
66
import classNames from 'classnames';
77
import React, { memo } from 'react';
8-
import { fallback, literal, object, optional, pipe, readonly, string, union, type InferInput } from 'valibot';
8+
import { object, optional, pipe, readonly, string, type InferInput } from 'valibot';
99

1010
import BasicConnectivityStatus from './BasicConnectivityStatus';
1111
import BasicToaster from './BasicToaster';
@@ -42,14 +42,7 @@ const TRANSCRIPT_STYLE = {
4242
const basicWebChatPropsSchema = pipe(
4343
object({
4444
className: optional(string()),
45-
role: fallback(
46-
optional(
47-
// Subset of landmark roles: https://w3.org/TR/wai-aria/#landmark_roles
48-
union([literal('complementary'), literal('contentinfo'), literal('form'), literal('main'), literal('region')])
49-
),
50-
// Fallback to "complementary" if specified is not a valid landmark role.
51-
'complementary'
52-
)
45+
role: optional(string())
5346
}),
5447
readonly()
5548
);

0 commit comments

Comments
 (0)