Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .changelog/5918-fix-fluent-hidesendbox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- Fixed the Fluent theme ignoring `styleOptions.hideSendBox`, in PR [#5918](https://github.com/microsoft/BotFramework-WebChat/pull/5918), by [@OEvgeny](https://github.com/OEvgeny)
9 changes: 9 additions & 0 deletions __tests__/html2/fluentTheme/hideSendBox.copilot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<script>
location = './hideSendBox?variant=copilot';
</script>
</head>
<body></body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions __tests__/html2/fluentTheme/hideSendBox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
</head>
<body>
<main id="webchat"></main>
<script type="importmap">
{
"imports": {
"@testduet/wait-for": "https://esm.sh/@testduet/wait-for",
"botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js",
"botframework-webchat/": "/__dist__/packages/bundle/static/botframework-webchat/",
"botframework-webchat-fluent-theme": "/__dist__/packages/fluent-theme/static/botframework-webchat-fluent-theme.js",
"react": "/__dist__/packages/bundle/static/react.js",
"react-dom": "/__dist__/packages/bundle/static/react-dom.js",
"react-dom/client": "/__dist__/packages/bundle/static/react-dom/client.js"
}
}
</script>
<script type="module">
import '/test-harness.mjs';
import '/test-page-object.mjs';

import { waitFor } from '@testduet/wait-for';
import { createStoreWithOptions, ReactWebChat } from 'botframework-webchat';
import { FluentThemeProvider, testIds } from 'botframework-webchat-fluent-theme';
import { createElement } from 'react';
import { createRoot } from 'react-dom/client';

// TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line.
window.WebChat = { createStoreWithOptions };

run(async function () {
const { directLine, store } = testHelpers.createDirectLineEmulator();

// GIVEN: Web Chat with the Fluent theme (or its Copilot variant) and `hideSendBox: true`.
createRoot(document.getElementById('webchat')).render(
createElement(
FluentThemeProvider,
{ variant: new URLSearchParams(location.search).get('variant') || 'fluent' },
createElement(ReactWebChat, { directLine, store, styleOptions: { hideSendBox: true } })
)
);

await pageConditions.uiConnected();

// WHEN: The bot sends a message with suggested actions, which are shown inside the send box.
await directLine.emulateIncomingActivity({
from: { role: 'bot' },
suggestedActions: {
actions: [
{ title: 'Yes', type: 'imBack', value: 'Yes' },
{ title: 'No', type: 'imBack', value: 'No' }
]
},
text: 'Do you want to continue?',
type: 'message'
});

await pageConditions.numActivitiesShown(1);
await waitFor(() => expect(store.getState().suggestedActions).toHaveLength(2));

// THEN: The send box, its toolbar, and the suggested actions should not be rendered.
expect(pageElements.byTestId(testIds.sendBoxContainer)).toBeFalsy();
expect(pageElements.byTestId(testIds.sendBoxTextBox)).toBeFalsy();
expect(pageElements.byTestId(testIds.sendBoxSendButton)).toBeFalsy();
expect(pageElements.byTestId(testIds.sendBoxSuggestedAction)).toBeFalsy();

// THEN: The transcript shows the message, without a send box or suggested actions below it.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/api/src/StyleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ type StrictStyleOptions = {
* Send box styling
*/

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

/**
Expand Down
10 changes: 8 additions & 2 deletions packages/fluent-theme/src/components/sendBox/SendBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,16 @@ function SendBox(props: Props) {
);
}

const PrimarySendBox = memo((props: Exclude<Props, 'primary'>) => <SendBox {...props} isPrimary={true} />);
function PrimarySendBox(props: Exclude<Props, 'primary'>) {
const [{ hideSendBox }] = useStyleOptions();

return hideSendBox ? null : <SendBox {...props} isPrimary={true} />;
}

PrimarySendBox.displayName = 'PrimarySendBox';

const MemoizedPrimarySendBox = memo(PrimarySendBox);

export default memo(SendBox);

export { PrimarySendBox };
export { MemoizedPrimarySendBox as PrimarySendBox };
Loading