Skip to content

Commit 84d194b

Browse files
tdurnfordcorinagum
authored andcommitted
Clear suggested-actions on button click (#2190)
* Clear suggested-actions on button click * Updated CHANGELOG.md * Created clearSuggestedActions action * Removed setSuggestedActions from dispatchers * Modified clearSuggestedActions action
1 parent 3bc1b65 commit 84d194b

8 files changed

Lines changed: 25 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4343
- Removed [`redux-promise-middleware`](https://www.npmjs.com/package/redux-promise-middleware)
4444

4545
### Fixed
46-
- Fix [#2187](https://github.com/microsoft/BotFramework-WebChat/issues/2187). Bump core-js and update core-js modules on index-es5.js, by [@corinagum](https://github.com/corinagum) in PR [#2195](https://github.com/microsoft/BotFramework-WebChat/pull/2195)
46+
47+
- Fix [#2160](https://github.com/microsoft/BotFramework-WebChat/issues/2160). Clear suggested actions after clicking on a suggested actions of type `openUrl`, by [@tdurnford](https://github.com/tdurnford) in PR [#2190](https://github.com/microsoft/BotFramework-WebChat/pull/2190)
48+
- Fix [#2187](https://github.com/microsoft/BotFramework-WebChat/issues/2187). Bump core-js and update core-js modules on index-es5.js, by [@corinagum](https://github.com/corinagum) in PR [#2195](https://github.com/microsoft/BotFramework-WebChat/pull/2195)
49+
4750

4851
## [4.5.0] - 2019-07-10
4952

Loading

__tests__/stacked.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { imageSnapshotOptions, timeouts } from './constants.json';
22

33
import allImagesLoaded from './setup/conditions/allImagesLoaded';
44
import minNumActivitiesShown from './setup/conditions/minNumActivitiesShown';
5+
import scrollToBottomCompleted from './setup/conditions/scrollToBottomCompleted';
56
import uiConnected from './setup/conditions/uiConnected';
67

78
// selenium-webdriver API doc:
@@ -18,6 +19,7 @@ describe('stacked without avatar initials', () => {
1819

1920
await driver.wait(minNumActivitiesShown(2), timeouts.directLine);
2021
await driver.wait(allImagesLoaded(), timeouts.fetch);
22+
await driver.wait(scrollToBottomCompleted(), timeouts.scrollToBottom);
2123

2224
expect(await driver.takeScreenshot()).toMatchImageSnapshot(imageSnapshotOptions);
2325
});

packages/component/src/Composer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
1010
import React from 'react';
1111

1212
import {
13+
clearSuggestedActions,
1314
connect as createConnectAction,
1415
createStore,
1516
disconnect,
@@ -46,6 +47,7 @@ import shallowEquals from './Utils/shallowEquals';
4647
const EMPTY_ARRAY = [];
4748

4849
const DISPATCHERS = {
50+
clearSuggestedActions,
4951
markActivity,
5052
postActivity,
5153
sendEvent,

packages/component/src/SendBox/SuggestedAction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ const SUGGESTED_ACTION_CSS = css({
1616

1717
const connectSuggestedAction = (...selectors) =>
1818
connectToWebChat(
19-
({ disabled, language, onCardAction }, { displayText, text, type, value }) => ({
19+
({ clearSuggestedActions, disabled, language, onCardAction }, { displayText, text, type, value }) => ({
2020
click: () => {
2121
onCardAction({ displayText, text, type, value });
22+
type === 'openUrl' && clearSuggestedActions();
2223
},
2324
disabled,
2425
language
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const CLEAR_SUGGESTED_ACTIONS = 'WEB_CHAT/CLEAR_SUGGESTED_ACTIONS';
2+
3+
export default function clearSuggestedActions() {
4+
return {
5+
type: CLEAR_SUGGESTED_ACTIONS
6+
};
7+
}
8+
9+
export { CLEAR_SUGGESTED_ACTIONS };

packages/core/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* global process:readonly */
22

3+
import clearSuggestedActions from './actions/clearSuggestedActions';
34
import connect from './actions/connect';
45
import createStore from './createStore';
56
import disconnect from './actions/disconnect';
@@ -30,6 +31,7 @@ const Constants = { ActivityClientState, DictateState };
3031
const version = process.env.NPM_PACKAGE_VERSION;
3132

3233
export {
34+
clearSuggestedActions,
3335
connect,
3436
Constants,
3537
createStore,

packages/core/src/reducers/suggestedActions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CLEAR_SUGGESTED_ACTIONS } from '../actions/clearSuggestedActions';
12
import { SET_SUGGESTED_ACTIONS } from '../actions/setSuggestedActions';
23

34
const DEFAULT_STATE = [];
@@ -7,7 +8,9 @@ export default function suggestedActions(state = DEFAULT_STATE, { payload = {},
78
case SET_SUGGESTED_ACTIONS:
89
state = [].slice.call(payload.suggestedActions || []);
910
break;
10-
11+
case CLEAR_SUGGESTED_ACTIONS:
12+
state = DEFAULT_STATE;
13+
break;
1114
default:
1215
break;
1316
}

0 commit comments

Comments
 (0)