Skip to content

Commit df6ebeb

Browse files
authored
Merge branch 'master' into feat-redux-hooks-9
2 parents f440eed + 3826e98 commit df6ebeb

16 files changed

Lines changed: 230 additions & 56 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3434
- Fixes [#2559](https://github.com/microsoft/BotFramework-WebChat/issues/2559). De-bump remark and strip-markdown, by [@corinagum](https://github.com/corinagum) in PR [#2576](https://github.com/microsoft/BotFramework-WebChat/pull/2576)
3535
- Fixes [#2512](https://github.com/microsoft/BotFramework-WebChat/issues/2512). Adds check to ensure Adaptive Card's content is an Object, by [@tdurnford](https://github.com/tdurnford) in PR [#2590](https://github.com/microsoft/BotFramework-WebChat/pull/2590)
3636
- Fixes [#1780](https://github.com/microsoft/BotFramework-WebChat/issues/1780), [#2277](https://github.com/microsoft/BotFramework-WebChat/issues/2277), and [#2285](https://github.com/microsoft/BotFramework-WebChat/issues/2285). Make Suggested Actions accessible, Fix Markdown card in carousel being read multiple times, and label widgets of Connectivity Status and Suggested Actions containers, by [@corinagum](https://github.com/corinagum) in PR [#2613](https://github.com/microsoft/BotFramework-WebChat/pull/2613)
37+
- Fixes [#2608](https://github.com/microsoft/BotFramework-WebChat/issues/2608). Focus will return to sendbox after clicking New Messages or a Suggested Actions button, by [@corinagum](https://github.com/corinagum) in PR [#2628](https://github.com/microsoft/BotFramework-WebChat/pull/2628)
3738

3839
### Added
3940

@@ -45,12 +46,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4546
- PR [#2544](https://github.com/microsoft/BotFramework-WebChat/pull/2544): `useAvatarForBot`, `useAvatarForUser`
4647
- PR [#2547](https://github.com/microsoft/BotFramework-WebChat/pull/2547): `useEmitTypingIndicator`, `usePeformCardAction`, `usePostActivity`, `useSendEvent`, `useSendFiles`, `useSendMessage`, `useSendMessageBack`, `useSendPostBack`
4748
- PR [#2548](https://github.com/microsoft/BotFramework-WebChat/pull/2548): `useDisabled`
49+
- PR [#2549](https://github.com/microsoft/BotFramework-WebChat/pull/2549): `useSuggestedActions`
4850
- PR [#2550](https://github.com/microsoft/BotFramework-WebChat/pull/2550): `useConnectivityStatus`, `useGroupTimestamp`, `useTimeoutForSend`, `useUserID`, `useUsername`
4951
- PR [#2551](https://github.com/microsoft/BotFramework-WebChat/pull/2551): `useLastTypingAt`, `useSendTypingIndicator`, `useTypingIndicator`
5052
- PR [#2552](https://github.com/microsoft/BotFramework-WebChat/pull/2552): `useFocusSendBox`, `useScrollToEnd`, `useSendBoxValue`, `useSubmitSendBox`, `useTextBoxSubmit`, `useTextBoxValue`
5153
- Bring your own Adaptive Cards package by specifying `adaptiveCardsPackage` prop, by [@compulim](https://github.com/compulim) in PR [#2543](https://github.com/microsoft/BotFramework-WebChat/pull/2543)
5254
- Fixes [#2597](https://github.com/microsoft/BotFramework-WebChat/issues/2597). Modify `watch` script to `start` and add `tableflip` script for throwing `node_modules`, by [@corinagum](https://github.com/corinagum) in PR [#2598](https://github.com/microsoft/BotFramework-WebChat/pull/2598)
5355
- `component`: Fixes [#2331](https://github.com/microsoft/BotFramework-WebChat/issues/2331). Updated timer to use React Hooks, by [@spyip](https://github.com/spyip) in PR [#2546](https://github.com/microsoft/BotFramework-WebChat/pull/2546)
56+
- Resolves [#2597](https://github.com/microsoft/BotFramework-WebChat/issues/2597). Modify `watch` script to `start` and add `tableflip` script for throwing `node_modules`, by [@corinagum](https://github.com/corinagum) in PR [#2598](https://github.com/microsoft/BotFramework-WebChat/pull/2598)
57+
- Adds `suggestedActionLayout` to `defaultStyleOptions`, by [@spyip](https://github.com/spyip), in PR [#2596](https://github.com/microsoft/BotFramework-WebChat/pull/2596)
58+
- Resolves [#2331](https://github.com/microsoft/BotFramework-WebChat/issues/2331). Updated timer to use React Hooks, by [@spyip](https://github.com/spyip) in PR [#2546](https://github.com/microsoft/BotFramework-WebChat/pull/2546)
5459

5560
### Changed
5661

Loading

__tests__/focus.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test('should not focus send box after clicking on send button', async () => {
2626
});
2727

2828
// Verification of fix of #1971, https://github.com/microsoft/BotFramework-WebChat/issues/1971
29-
test('should not focus send box after clicking on suggested actions', async () => {
29+
test('SHOULD focus send box after clicking on suggested actions', async () => {
3030
const { driver, pageObjects } = await setupWebDriver();
3131

3232
await driver.wait(uiConnected(), timeouts.directLine);
@@ -36,7 +36,7 @@ test('should not focus send box after clicking on suggested actions', async () =
3636

3737
await pageObjects.clickSuggestedActionButton(0);
3838

39-
await expect(sendBoxTextBoxFocused().fn(driver)).resolves.toBeFalsy();
39+
await expect(sendBoxTextBoxFocused().fn(driver)).resolves.toBeTruthy();
4040
});
4141

4242
// Verification of fix of #1971, https://github.com/microsoft/BotFramework-WebChat/issues/1971
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { timeouts } from '../constants.json';
2+
3+
import suggestedActionsShown from '../setup/conditions/suggestedActionsShown';
4+
import uiConnected from '../setup/conditions/uiConnected';
5+
6+
// selenium-webdriver API doc:
7+
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html
8+
9+
jest.setTimeout(timeouts.test);
10+
11+
test('getter should get suggested actions', async () => {
12+
const { driver, pageObjects } = await setupWebDriver();
13+
14+
await driver.wait(uiConnected(), timeouts.directLine);
15+
16+
await pageObjects.sendMessageViaSendBox('suggested-actions');
17+
await driver.wait(suggestedActionsShown(), timeouts.directLine);
18+
19+
await expect(pageObjects.runHook('useSuggestedActions', [], result => result[0])).resolves.toMatchInlineSnapshot(`
20+
Array [
21+
Object {
22+
"image": "https://tdurnford.github.io/BotFramework-Offline-MockBot/assets/square-icon.png",
23+
"title": "IM back as string",
24+
"type": "imBack",
25+
"value": "postback imback-string",
26+
},
27+
Object {
28+
"image": "https://tdurnford.github.io/BotFramework-Offline-MockBot/assets/square-icon-red.png",
29+
"title": "Post back as string",
30+
"type": "postBack",
31+
"value": "postback postback-string",
32+
},
33+
Object {
34+
"image": "https://tdurnford.github.io/BotFramework-Offline-MockBot/assets/square-icon-green.png",
35+
"text": "Some text",
36+
"title": "Post back as JSON",
37+
"type": "postBack",
38+
"value": Object {
39+
"hello": "World!",
40+
},
41+
},
42+
Object {
43+
"displayText": "say Hello World!",
44+
"image": "https://tdurnford.github.io/BotFramework-Offline-MockBot/assets/square-icon-purple.png",
45+
"text": "Some text",
46+
"title": "Message back as JSON with display text",
47+
"type": "messageBack",
48+
"value": Object {
49+
"hello": "World!",
50+
},
51+
},
52+
Object {
53+
"image": "https://tdurnford.github.io/BotFramework-Offline-MockBot/assets/square-icon-purple.png",
54+
"title": "Message back as JSON without display text",
55+
"type": "messageBack",
56+
"value": Object {
57+
"hello": "World!",
58+
},
59+
},
60+
Object {
61+
"displayText": "Aloha",
62+
"image": "https://tdurnford.github.io/BotFramework-Offline-MockBot/assets/square-icon-purple.png",
63+
"text": "echo Hello",
64+
"title": "Message back as string with display text",
65+
"type": "messageBack",
66+
"value": null,
67+
},
68+
]
69+
`);
70+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { By, until } from 'selenium-webdriver';
22

33
export default function suggestedActionsShown() {
4-
return until.elementLocated(By.css('[role="form"] ul'));
4+
return until.elementLocated(By.css('[role="form"] > :not(.main) button'));
55
}

__tests__/suggestedActions.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ describe('suggested-actions command', () => {
2828
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
2929
});
3030

31+
test('should show correctly formatted buttons when suggested actions are displayed as stacked', async () => {
32+
const { driver, pageObjects } = await setupWebDriver({
33+
props: { styleOptions: { suggestedActionLayout: 'stacked' } }
34+
});
35+
36+
await driver.wait(uiConnected(), timeouts.directLine);
37+
await pageObjects.sendMessageViaSendBox('suggested-actions', { waitForSend: true });
38+
39+
await driver.wait(suggestedActionsShown(), timeouts.directLine);
40+
await driver.wait(allImagesLoaded(), 2000);
41+
42+
const base64PNG = await driver.takeScreenshot();
43+
44+
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
45+
});
46+
3147
test('should show response from bot and no text from user on imback', async () => {
3248
const { driver, pageObjects } = await setupWebDriver();
3349

@@ -174,4 +190,23 @@ describe('suggested-actions command', () => {
174190

175191
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
176192
});
193+
194+
test('should show suggested actions with larger images as stacked', async () => {
195+
const styleOptions = {
196+
suggestedActionHeight: 80,
197+
suggestedActionImageHeight: 60,
198+
suggestedActionLayout: 'stacked'
199+
};
200+
const { driver, pageObjects } = await setupWebDriver({ props: { styleOptions } });
201+
202+
await driver.wait(uiConnected(), timeouts.directLine);
203+
await pageObjects.sendMessageViaSendBox('emptycard', { waitForSend: true });
204+
205+
await driver.wait(suggestedActionsShown(), timeouts.directLine);
206+
await driver.wait(allImagesLoaded(), 2000);
207+
208+
const base64PNG = await driver.takeScreenshot();
209+
210+
expect(base64PNG).toMatchImageSnapshot(imageSnapshotOptions);
211+
});
177212
});

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/component/src/Activity/ScrollToEndButton.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@ import { StateContext as ScrollToBottomStateContext } from 'react-scroll-to-bott
22

33
import classNames from 'classnames';
44
import PropTypes from 'prop-types';
5-
import React from 'react';
5+
import React, { useCallback } from 'react';
66

77
import Localize from '../Localization/Localize';
8+
import useFocusSendBox from '../hooks/useFocusSendBox';
89
import useScrollToEnd from '../hooks/useScrollToEnd';
910
import useStyleSet from '../hooks/useStyleSet';
1011

1112
const ScrollToEndButton = ({ className }) => {
1213
const [{ scrollToEndButton: scrollToEndButtonStyleSet }] = useStyleSet();
14+
const focusSendBox = useFocusSendBox();
1315
const scrollToEnd = useScrollToEnd();
1416

17+
const handleClick = useCallback(() => {
18+
scrollToEnd();
19+
focusSendBox();
20+
}, [focusSendBox, scrollToEnd]);
21+
1522
return (
16-
<button className={classNames(scrollToEndButtonStyleSet + '', className + '')} onClick={scrollToEnd} type="button">
23+
<button className={classNames(scrollToEndButtonStyleSet + '', className + '')} onClick={handleClick} type="button">
1724
<Localize text="New messages" />
1825
</button>
1926
);

packages/component/src/SendBox/SuggestedAction.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ import React, { useCallback } from 'react';
55

66
import connectToWebChat from '../connectToWebChat';
77
import useDisabled from '../hooks/useDisabled';
8+
import useFocusSendBox from '../hooks/useFocusSendBox';
89
import usePerformCardAction from '../hooks/usePerformCardAction';
910
import useStyleSet from '../hooks/useStyleSet';
11+
import useSuggestedActions from '../hooks/useSuggestedActions';
1012

1113
const SUGGESTED_ACTION_CSS = css({
12-
display: 'inline-block',
14+
display: 'flex',
15+
flexDirection: 'column',
1316
whiteSpace: 'initial',
1417

1518
'& > button': {
16-
display: 'flex'
19+
display: 'flex',
20+
overflow: 'hidden'
1721
}
1822
});
1923

@@ -30,27 +34,18 @@ const connectSuggestedAction = (...selectors) =>
3034
...selectors
3135
);
3236

33-
const SuggestedAction = ({
34-
'aria-hidden': ariaHidden,
35-
buttonText,
36-
clearSuggestedActions,
37-
displayText,
38-
image,
39-
text,
40-
type,
41-
value
42-
}) => {
37+
const SuggestedAction = ({ 'aria-hidden': ariaHidden, buttonText, displayText, image, text, type, value }) => {
38+
const [_, setSuggestedActions] = useSuggestedActions();
4339
const [{ suggestedAction: suggestedActionStyleSet }] = useStyleSet();
4440
const [disabled] = useDisabled();
41+
const focusSendBox = useFocusSendBox();
4542
const performCardAction = usePerformCardAction();
4643

4744
const handleClick = useCallback(() => {
4845
performCardAction({ displayText, text, type, value });
49-
type === 'openUrl' && clearSuggestedActions();
50-
51-
// TODO: Use the following line when setSuggestedActions hook is merged
52-
// type === 'openUrl' && setSuggestedActions([]);
53-
}, [clearSuggestedActions, displayText, performCardAction, text, type, value]);
46+
type === 'openUrl' && setSuggestedActions([]);
47+
focusSendBox();
48+
}, [displayText, focusSendBox, performCardAction, setSuggestedActions, text, type, value]);
5449

5550
return (
5651
<div aria-hidden={ariaHidden} className={classNames(suggestedActionStyleSet + '', SUGGESTED_ACTION_CSS + '')}>
@@ -74,14 +69,13 @@ SuggestedAction.defaultProps = {
7469
SuggestedAction.propTypes = {
7570
'aria-hidden': PropTypes.bool,
7671
buttonText: PropTypes.string.isRequired,
77-
clearSuggestedActions: PropTypes.func.isRequired,
7872
displayText: PropTypes.string,
7973
image: PropTypes.string,
8074
text: PropTypes.string,
8175
type: PropTypes.string,
8276
value: PropTypes.any
8377
};
8478

85-
export default connectSuggestedAction(({ clearSuggestedActions }) => ({ clearSuggestedActions }))(SuggestedAction);
79+
export default SuggestedAction;
8680

8781
export { connectSuggestedAction };

0 commit comments

Comments
 (0)