Skip to content

Commit 8b4ce2f

Browse files
committed
Add styleOptions.sendBoxAttachmentBarMaxHeight
1 parent 58e1dfb commit 8b4ce2f

6 files changed

Lines changed: 81 additions & 2 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
5+
<script crossorigin="anonymous" src="/test-harness.js"></script>
6+
<script crossorigin="anonymous" src="/test-page-object.js"></script>
7+
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
8+
</head>
9+
<body>
10+
<main id="webchat"></main>
11+
<script type="importmap">
12+
{
13+
"imports": {
14+
"@testduet/wait-for": "https://esm.sh/@testduet/wait-for",
15+
"@testing-library/dom": "https://esm.sh/@testing-library/dom"
16+
}
17+
}
18+
</script>
19+
<script type="module">
20+
import { waitFor } from '@testduet/wait-for';
21+
import { queryAllByTestId } from '@testing-library/dom';
22+
23+
const {
24+
testHelpers: { createDirectLineEmulator },
25+
WebChat: { createDirectLine, testIds }
26+
} = window;
27+
28+
run(async function () {
29+
// We enable reduced motion by default, disable it first.
30+
await host.sendDevToolsCommand('Emulation.setEmulatedMedia', {
31+
features: [{ name: 'prefers-reduced-motion', value: '' }]
32+
});
33+
34+
const { directLine, store } = createDirectLineEmulator();
35+
36+
function render(props) {
37+
WebChat.renderWebChat(
38+
{
39+
directLine,
40+
store,
41+
...props
42+
},
43+
document.getElementById('webchat')
44+
);
45+
}
46+
47+
render();
48+
49+
await pageConditions.uiConnected();
50+
51+
for (let index = 0; index < 10; index++) {
52+
await host.upload(pageElements.uploadButton(), 'empty.zip');
53+
54+
await waitFor(() =>
55+
expect(queryAllByTestId(document, testIds.sendBoxAttachmentBarItem)).toHaveLength(index + 1)
56+
);
57+
}
58+
59+
// THEN: With 1 attachment, they should appear as text-only.
60+
await host.snapshot('local');
61+
62+
// WHEN: styleOptions.sendBoxAttachmentBarMaxHeight is set to 200px.
63+
render({ styleOptions: { sendBoxAttachmentBarMaxHeight: 200 } });
64+
65+
// THEN: With 1 attachment, they should appear as text-only.
66+
await host.snapshot('local');
67+
});
68+
</script>
69+
</body>
70+
</html>
16.8 KB
Loading
20.6 KB
Loading

packages/api/src/StyleOptions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,14 @@ type StyleOptions = {
964964

965965
/**
966966
* Send box: maximum number of attachment item to preview as thumbnail before showing as text-only.
967+
* Send box: maximum height of the attachment bar.
968+
*
969+
* @default 114
970+
*/
971+
sendBoxAttachmentBarMaxHeight?: number;
972+
973+
/**
974+
* Send box: maximum number of attachment item to preview as thumbnail before showing as list item.
967975
*
968976
* @default 3
969977
*/

packages/api/src/defaultStyleOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ const DEFAULT_OPTIONS: Required<StyleOptions> = {
314314
groupActivitiesBy: ['sender', 'status'],
315315

316316
// Send box attachment bar
317+
sendBoxAttachmentBarMaxHeight: 114,
317318
sendBoxAttachmentBarMaxThumbnail: 3
318319
};
319320

packages/component/src/SendBox/AttachmentBar/AttachmentBarStyle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { StrictStyleOptions } from 'botframework-webchat-api';
22
import { type StyleSet } from '../../Styles/StyleSet/types/StyleSet';
33

4-
export default function createSendBoxAttachmentBarStyle(_: StrictStyleOptions) {
4+
export default function createSendBoxAttachmentBarStyle({ sendBoxAttachmentBarMaxHeight }: StrictStyleOptions) {
55
return {
66
'&.webchat__send-box-attachment-bar': {
77
display: 'content',
88

99
'&.webchat__send-box-attachment-bar--as-list-item': {
10-
maxHeight: '114px',
10+
maxHeight: `${sendBoxAttachmentBarMaxHeight}px`,
1111
overflowY: 'auto',
1212
scrollbarGutter: 'stable',
1313
scrollbarWidth: 'thin'

0 commit comments

Comments
 (0)