diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js
index 3d946f9fc..29ecfb0e7 100644
--- a/client/coral-admin/src/routes/Moderation/components/Comment.js
+++ b/client/coral-admin/src/routes/Moderation/components/Comment.js
@@ -129,7 +129,7 @@ class Comment extends React.Component {
Story: {comment.asset.title}
{!props.currentAsset &&
- {t('modqueue.moderate')}}
+ {t('modqueue.moderate')}}
{
-
+
);
};
@@ -89,7 +89,7 @@ const StorySearch = (props) => {
StorySearch.propTypes = {
search: PropTypes.func.isRequired,
goToStory: PropTypes.func.isRequired,
- closeSearch: PropTypes.func.isRequired,
+ clearAndCloseSearch: PropTypes.func.isRequired,
moderation: PropTypes.object.isRequired,
handleSearchChange: PropTypes.func.isRequired,
assetId: PropTypes.string
diff --git a/client/coral-admin/src/routes/Moderation/containers/StorySearch.js b/client/coral-admin/src/routes/Moderation/containers/StorySearch.js
index f4ab6f23e..d5a0ad243 100644
--- a/client/coral-admin/src/routes/Moderation/containers/StorySearch.js
+++ b/client/coral-admin/src/routes/Moderation/containers/StorySearch.js
@@ -3,6 +3,7 @@ import {compose, gql} from 'react-apollo';
import StorySearch from '../components/StorySearch';
import {withRouter} from 'react-router';
import withQuery from 'coral-framework/hocs/withQuery';
+import {isEmpty} from 'lodash';
class StorySearchContainer extends React.Component {
constructor(props) {
@@ -13,6 +14,23 @@ class StorySearchContainer extends React.Component {
};
}
+ componentWillUnmount() {
+ this.props.storySearchChange('');
+ }
+
+ clearSearch = () => {
+ this.setState({searchValue: ''}, () => {
+ this.search();
+ });
+ }
+
+ clearAndCloseSearch = () => {
+ if (!isEmpty(this.state.searchValue)) {
+ this.clearSearch();
+ }
+ this.props.closeSearch();
+ }
+
handleSearchChange = (e) => {
const {value} = e.target;
this.setState({
@@ -23,7 +41,7 @@ class StorySearchContainer extends React.Component {
handleEsc = (e) => {
if (e.key === 'Escape') {
e.preventDefault();
- this.props.closeSearch();
+ this.clearAndCloseSearch();
}
}
@@ -40,15 +58,15 @@ class StorySearchContainer extends React.Component {
}
goToStory = (id) => {
- const {router, closeSearch} = this.props;
+ const {router} = this.props;
router.push(`/admin/moderate/all/${id}`);
- closeSearch();
+ this.clearAndCloseSearch();
}
goToModerateAll = () => {
- const {router, closeSearch} = this.props;
+ const {router} = this.props;
router.push('/admin/moderate/all');
- closeSearch();
+ this.clearAndCloseSearch();
}
render () {
@@ -61,6 +79,7 @@ class StorySearchContainer extends React.Component {
handleEnter={this.handleEnter}
searchValue={this.state.searchValue}
handleSearchChange={this.handleSearchChange}
+ clearAndCloseSearch={this.clearAndCloseSearch}
{...this.props}
/>
);