Skip to content

Commit 270fc46

Browse files
committed
Activity status should not show feedback form
1 parent 488ce72 commit 270fc46

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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="https://unpkg.com/@babel/standalone@7.8.7/babel.min.js"></script>
6+
<script crossorigin="anonymous" src="https://unpkg.com/react@16.8.6/umd/react.production.min.js"></script>
7+
<script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js"></script>
8+
<script crossorigin="anonymous" src="/test-harness.js"></script>
9+
<script crossorigin="anonymous" src="/test-page-object.js"></script>
10+
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
11+
</head>
12+
<body>
13+
<main id="webchat"></main>
14+
<script type="text/babel">
15+
run(async function () {
16+
const {
17+
React,
18+
ReactDOM: { render },
19+
WebChat: { ReactWebChat }
20+
} = window; // Imports in UMD fashion.
21+
22+
const { directLine, store } = testHelpers.createDirectLineEmulator();
23+
24+
const App = () => (
25+
<React.Fragment>
26+
<ReactWebChat
27+
directLine={directLine}
28+
store={store}
29+
/>
30+
</React.Fragment>
31+
);
32+
33+
render(<App />, document.getElementById('webchat'));
34+
35+
await pageConditions.uiConnected();
36+
37+
await directLine.emulateIncomingActivity({
38+
type: 'message',
39+
id: 'a-00001',
40+
timestamp: 0,
41+
text: 'This is a a test message without a disclaimer',
42+
from: {
43+
role: 'bot'
44+
},
45+
locale: 'en-US',
46+
entities: [],
47+
channelData: {
48+
feedbackLoop: {
49+
type: 'default'
50+
}
51+
}
52+
});
53+
54+
pageElements.byTestId('send box text area').focus();
55+
await host.sendShiftTab(3);
56+
57+
await host.sendKeys('ENTER');
58+
await host.sendKeys('ENTER');
59+
60+
61+
await expect(pageElements.byTestId('feedback sendbox')).toBeFalsy();
62+
63+
await host.snapshot('local');
64+
});
65+
</script>
66+
</body>
67+
</html>
12.6 KB
Loading

packages/component/src/ActivityFeedback/providers/ActivityFeedbackComposer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import dereferenceBlankNodes from '../../Utils/JSONLinkedData/dereferenceBlankNo
1313
import hasFeedbackLoop from '../private/hasFeedbackLoop';
1414
import ActivityFeedbackContext, { type ActivityFeedbackContextType } from './private/ActivityFeedbackContext';
1515

16-
const { usePonyfill, usePostActivity } = hooks;
16+
const { usePonyfill, usePostActivity, useStyleOptions } = hooks;
1717

1818
type ActivityFeedbackComposerProps = Readonly<{
1919
activity: WebChatActivity;
@@ -188,7 +188,9 @@ function ActivityFeedbackComposer({ children, activity: activityFromProps }: Act
188188
[actionsRef, actionStateRef, activityRef, postActivity, setActionStateWithRefresh]
189189
);
190190

191-
const shouldShowFeedbackForm = hasFeedbackLoop(activity);
191+
const [{ feedbackActionsPlacement }] = useStyleOptions();
192+
193+
const shouldShowFeedbackForm = hasFeedbackLoop(activity) && feedbackActionsPlacement === 'activity-actions';
192194
const shouldShowFeedbackFormRef = useRefFrom(shouldShowFeedbackForm);
193195

194196
const shouldShowFeedbackFormState = useMemo<readonly [boolean]>(

0 commit comments

Comments
 (0)