Skip to content

Commit d62d9a2

Browse files
author
Eugene Olonov
committed
Fix Fluent theme ignoring styleOptions.hideSendBox
1 parent 705befe commit d62d9a2

7 files changed

Lines changed: 96 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Legends:
6363
- Fixed video and animation cards disappearing in production builds when the video URL is relative or invalid, in PR [#5889](https://github.com/microsoft/BotFramework-WebChat/pull/5889), by [@OEvgeny](https://github.com/OEvgeny)
6464
- Fixed timestamps always using the 12-hour clock, such as "4:41 PM" instead of "16:41" in German, in PR [#5920](https://github.com/microsoft/BotFramework-WebChat/pull/5920), by [@OEvgeny](https://github.com/OEvgeny)
6565
- Fixed carousel cards focused with <kbd>TAB</kbd> staying partially out of view, in PR [#5926](https://github.com/microsoft/BotFramework-WebChat/pull/5926), by [@OEvgeny](https://github.com/OEvgeny)
66+
- Fixed the Fluent theme ignoring `styleOptions.hideSendBox`, in PR [#XXXX](https://github.com/microsoft/BotFramework-WebChat/pull/XXXX), by [@OEvgeny](https://github.com/OEvgeny)
6667

6768
## [4.19.2] - 2026-10-08
6869

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<script>
5+
location = './hideSendBox?variant=copilot';
6+
</script>
7+
</head>
8+
<body></body>
9+
</html>
4.77 KB
Loading
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
"@testduet/wait-for": "https://esm.sh/@testduet/wait-for",
12+
"botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js",
13+
"botframework-webchat/": "/__dist__/packages/bundle/static/botframework-webchat/",
14+
"botframework-webchat-fluent-theme": "/__dist__/packages/fluent-theme/static/botframework-webchat-fluent-theme.js",
15+
"react": "/__dist__/packages/bundle/static/react.js",
16+
"react-dom": "/__dist__/packages/bundle/static/react-dom.js",
17+
"react-dom/client": "/__dist__/packages/bundle/static/react-dom/client.js"
18+
}
19+
}
20+
</script>
21+
<script type="module">
22+
import '/test-harness.mjs';
23+
import '/test-page-object.mjs';
24+
25+
import { waitFor } from '@testduet/wait-for';
26+
import { createStoreWithOptions, ReactWebChat } from 'botframework-webchat';
27+
import { FluentThemeProvider, testIds } from 'botframework-webchat-fluent-theme';
28+
import { createElement } from 'react';
29+
import { createRoot } from 'react-dom/client';
30+
31+
// TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line.
32+
window.WebChat = { createStoreWithOptions };
33+
34+
run(async function () {
35+
const { directLine, store } = testHelpers.createDirectLineEmulator();
36+
37+
// GIVEN: Web Chat with the Fluent theme (or its Copilot variant) and `hideSendBox: true`.
38+
createRoot(document.getElementById('webchat')).render(
39+
createElement(
40+
FluentThemeProvider,
41+
{ variant: new URLSearchParams(location.search).get('variant') || 'fluent' },
42+
createElement(ReactWebChat, { directLine, store, styleOptions: { hideSendBox: true } })
43+
)
44+
);
45+
46+
await pageConditions.uiConnected();
47+
48+
// WHEN: The bot sends a message with suggested actions, which are shown inside the send box.
49+
await directLine.emulateIncomingActivity({
50+
from: { role: 'bot' },
51+
suggestedActions: {
52+
actions: [
53+
{ title: 'Yes', type: 'imBack', value: 'Yes' },
54+
{ title: 'No', type: 'imBack', value: 'No' }
55+
]
56+
},
57+
text: 'Do you want to continue?',
58+
type: 'message'
59+
});
60+
61+
await pageConditions.numActivitiesShown(1);
62+
await waitFor(() => expect(store.getState().suggestedActions).toHaveLength(2));
63+
64+
// THEN: The send box, its toolbar, and the suggested actions should not be rendered.
65+
expect(pageElements.byTestId(testIds.sendBoxContainer)).toBeFalsy();
66+
expect(pageElements.byTestId(testIds.sendBoxTextBox)).toBeFalsy();
67+
expect(pageElements.byTestId(testIds.sendBoxSendButton)).toBeFalsy();
68+
expect(pageElements.byTestId(testIds.sendBoxSuggestedAction)).toBeFalsy();
69+
70+
// THEN: The transcript shows the message, without a send box or suggested actions below it.
71+
await host.snapshot('local');
72+
});
73+
</script>
74+
</body>
75+
</html>
5.58 KB
Loading

‎packages/api/src/StyleOptions.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ type StrictStyleOptions = {
283283
* Send box styling
284284
*/
285285

286+
/**
287+
* `true` to hide the send box and its suggested actions, otherwise, `false`. Defaults to `false`.
288+
*/
286289
hideSendBox: boolean | undefined;
287290

288291
/**

‎packages/fluent-theme/src/components/sendBox/SendBox.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,16 @@ function SendBox(props: Props) {
297297
);
298298
}
299299

300-
const PrimarySendBox = memo((props: Exclude<Props, 'primary'>) => <SendBox {...props} isPrimary={true} />);
300+
function PrimarySendBox(props: Exclude<Props, 'primary'>) {
301+
const [{ hideSendBox }] = useStyleOptions();
302+
303+
return hideSendBox ? null : <SendBox {...props} isPrimary={true} />;
304+
}
301305

302306
PrimarySendBox.displayName = 'PrimarySendBox';
303307

308+
const MemoizedPrimarySendBox = memo(PrimarySendBox);
309+
304310
export default memo(SendBox);
305311

306-
export { PrimarySendBox };
312+
export { MemoizedPrimarySendBox as PrimarySendBox };

0 commit comments

Comments
 (0)