diff --git a/client/coral-admin/src/actions/moderation.js b/client/coral-admin/src/actions/moderation.js
index a3ff2ca3e..18e31091f 100644
--- a/client/coral-admin/src/actions/moderation.js
+++ b/client/coral-admin/src/actions/moderation.js
@@ -34,3 +34,8 @@ export const storySearchChange = (value) => ({
export const clearState = () => ({
type: actions.MODERATION_CLEAR_STATE
});
+
+export const selectCommentId = (id) => ({
+ type: actions.MODERATION_SELECT_COMMENT,
+ id,
+});
diff --git a/client/coral-admin/src/components/CommentDetails.js b/client/coral-admin/src/components/CommentDetails.js
index cd504a40f..418be0354 100644
--- a/client/coral-admin/src/components/CommentDetails.js
+++ b/client/coral-admin/src/components/CommentDetails.js
@@ -21,10 +21,11 @@ class CommentDetails extends Component {
this.setState((state) => ({
showDetail: !state.showDetail
}));
+ this.props.clearHeightCache && this.props.clearHeightCache();
}
render() {
- const {data, root, comment} = this.props;
+ const {data, root, comment, clearHeightCache} = this.props;
const {showDetail} = this.state;
const queryData = {
root,
@@ -44,12 +45,14 @@ class CommentDetails extends Component {
{showDetail && }
@@ -61,6 +64,7 @@ CommentDetails.propTypes = {
data: PropTypes.object.isRequired,
root: PropTypes.object.isRequired,
comment: PropTypes.object.isRequired,
+ clearHeightCache: PropTypes.func,
};
export default CommentDetails;
diff --git a/client/coral-admin/src/constants/moderation.js b/client/coral-admin/src/constants/moderation.js
index cae13947d..8eb939d76 100644
--- a/client/coral-admin/src/constants/moderation.js
+++ b/client/coral-admin/src/constants/moderation.js
@@ -6,3 +6,4 @@ export const SHOW_STORY_SEARCH = 'SHOW_STORY_SEARCH';
export const HIDE_STORY_SEARCH = 'HIDE_STORY_SEARCH';
export const STORY_SEARCH_CHANGE_VALUE = 'STORY_SEARCH_CHANGE_VALUE';
export const MODERATION_CLEAR_STATE = 'MODERATION_CLEAR_STATE';
+export const MODERATION_SELECT_COMMENT = 'MODERATION_SELECT_COMMENT';
diff --git a/client/coral-admin/src/reducers/moderation.js b/client/coral-admin/src/reducers/moderation.js
index 43ae81573..6a64b380a 100644
--- a/client/coral-admin/src/reducers/moderation.js
+++ b/client/coral-admin/src/reducers/moderation.js
@@ -7,6 +7,7 @@ const initialState = {
storySearchString: '',
shortcutsNoteVisible: 'show',
sortOrder: 'DESC',
+ selectedCommentId: '',
};
export default function moderation (state = initialState, action) {
@@ -51,6 +52,11 @@ export default function moderation (state = initialState, action) {
...state,
sortOrder: action.order,
};
+ case actions.MODERATION_SELECT_COMMENT:
+ return {
+ ...state,
+ selectedCommentId: action.id,
+ };
default:
return state;
}
diff --git a/client/coral-admin/src/routes/Moderation/components/AutoLoadMore.js b/client/coral-admin/src/routes/Moderation/components/AutoLoadMore.js
new file mode 100644
index 000000000..4ba7c3298
--- /dev/null
+++ b/client/coral-admin/src/routes/Moderation/components/AutoLoadMore.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import {Spinner} from 'coral-ui';
+import PropTypes from 'prop-types';
+
+/**
+ * AutoLoadMore with call `loadMore` the moment it is rendered and shows a Spinner.
+ */
+class AutoLoadMore extends React.Component {
+ componentDidMount() {
+ if(!this.props.loading) {
+ this.props.loadMore();
+ }
+ }
+
+ render() {
+ return ;
+ }
+}
+
+AutoLoadMore.propTypes = {
+ loading: PropTypes.bool.isRequired,
+ loadMore: PropTypes.func.isRequired,
+};
+
+export default AutoLoadMore;
diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.css b/client/coral-admin/src/routes/Moderation/components/Comment.css
index 10cc707fb..119688b73 100644
--- a/client/coral-admin/src/routes/Moderation/components/Comment.css
+++ b/client/coral-admin/src/routes/Moderation/components/Comment.css
@@ -10,7 +10,9 @@
position: relative;
transition: all 200ms;
padding: 10px 0;
+ margin-top: 13px;
min-height: 0;
+ outline: 0;
/*
Fix rendering issues in Safari by promoting this
@@ -25,6 +27,10 @@
}
}
+.dangling {
+ background-color: #efefef;
+}
+
.container {
padding: 0 14px;
}
diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js
index cea49720b..293071cec 100644
--- a/client/coral-admin/src/routes/Moderation/components/Comment.js
+++ b/client/coral-admin/src/routes/Moderation/components/Comment.js
@@ -20,6 +20,16 @@ import t, {timeago} from 'coral-framework/services/i18n';
class Comment extends React.Component {
+ ref = null;
+
+ handleRef = (ref) => this.ref = ref;
+
+ handleFocusOrClick = () => {
+ if (!this.props.selected) {
+ this.props.selectComment();
+ }
+ };
+
showSuspendUserDialog = () => {
const {comment, showSuspendUserDialog} = this.props;
return showSuspendUserDialog({
@@ -55,6 +65,12 @@ class Comment extends React.Component {
: this.props.rejectComment({commentId: this.props.comment.id})
);
+ componentDidUpdate(prev) {
+ if (!prev.selected && this.props.selected) {
+ this.ref.focus();
+ }
+ }
+
render() {
const {
comment,
@@ -65,6 +81,8 @@ class Comment extends React.Component {
root: {settings},
currentUserId,
currentAsset,
+ clearHeightCache,
+ dangling,
} = this.props;
const selectionStateCSS = selected ? 'mdl-shadow--16dp' : 'mdl-shadow--2dp';
@@ -73,8 +91,11 @@ class Comment extends React.Component {
return (