[CORL-732] allow navigation via j/k in single comment view (#2712)

* allow navigation via j/k in single comment view

* update snaps
This commit is contained in:
Tessa Thornton
2019-11-22 17:59:46 +00:00
committed by Wyatt Johnson
parent ddedf4dc7e
commit 09cf8c5490
3 changed files with 13 additions and 4 deletions
@@ -113,6 +113,7 @@ const Queue: FunctionComponent<Props> = ({
<QueueWrapper
comments={comments}
singleView={singleView}
selected={selectedComment}
card={(comment, i) => (
<ModerateCardContainer
key={comment.id}
@@ -14,27 +14,33 @@ interface Props {
c: { id: string } & PropTypesOf<typeof ModerateCardContainer>["comment"],
i: number
) => ReactNode;
selected: number | null;
}
const QueueWrapper: FunctionComponent<Props> = ({
singleView,
card,
comments,
selected,
}) => {
const commentsQueue = singleView ? [comments[0]] : comments;
if (singleView) {
return (
<>
{commentsQueue
{comments
// FIXME (Nick/Wyatt): Investigate why comments are coming back null
.filter(c => Boolean(c))
.map((c, i) => card(c, i))}
.map((c, i) => {
if (i === selected) {
return card(c, i);
}
return null;
})}
</>
);
}
return (
<TransitionGroup component={null} appear={false} enter={false} exit>
{commentsQueue
{comments
// FIXME (Nick/Wyatt): Investigate why comments are coming back null
.filter(c => Boolean(c))
.map((c, i) => (
@@ -8,6 +8,7 @@ exports[`renders correctly with load more 1`] = `
<QueueWrapper
card={[Function]}
comments={Array []}
selected={0}
singleView={false}
/>
<ForwardRef(forwardRef)
@@ -34,6 +35,7 @@ exports[`renders correctly without load more 1`] = `
<QueueWrapper
card={[Function]}
comments={Array []}
selected={0}
singleView={false}
/>
<UserHistoryDrawer