Skip to content

Commit 295533c

Browse files
authored
feat(threaded-replies): keep replies visible when loading more replies (#3133)
* feat(threaded-replies): keep replies visible when loading more replies
1 parent b291c50 commit 295533c

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

src/elements/content-sidebar/activity-feed/activity-feed/ActivityThread.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as React from 'react';
33
import { FormattedMessage } from 'react-intl';
44
import noop from 'lodash/noop';
55

6-
import LoadingIndicator from '../../../../components/loading-indicator';
76
import PlainButton from '../../../../components/plain-button';
87
import ActivityThreadReplies from './ActivityThreadReplies';
98
import ActivityThreadReplyForm from './ActivityThreadReplyForm';
@@ -113,19 +112,15 @@ const ActivityThread = ({
113112
<div className="bcs-ActivityThread" data-testid="activity-thread">
114113
{children}
115114

116-
{isRepliesLoading && (
117-
<div className="bcs-ActivityThread-loading" data-testid="activity-thread-loading">
118-
<LoadingIndicator />
119-
</div>
120-
)}
121115
{renderButton()}
122116

123-
{!isRepliesLoading && repliesTotalCount > 0 && repliesLength > 0 && (
117+
{repliesTotalCount > 0 && repliesLength > 0 && (
124118
<ActivityThreadReplies
125119
currentUser={currentUser}
126120
getAvatarUrl={getAvatarUrl}
127121
getMentionWithQuery={getMentionWithQuery}
128122
getUserProfileUrl={getUserProfileUrl}
123+
isRepliesLoading={isRepliesLoading}
129124
mentionSelectorContacts={mentionSelectorContacts}
130125
onDelete={onReplyDelete}
131126
onEdit={onReplyEdit}

src/elements/content-sidebar/activity-feed/activity-feed/ActivityThread.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,3 @@
2222
outline: auto;
2323
}
2424
}
25-
26-
.bcs-ActivityThread-loading {
27-
padding-bottom: $bdl-grid-unit * 5;
28-
}

src/elements/content-sidebar/activity-feed/activity-feed/ActivityThreadReplies.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22
import React from 'react';
33
import Comment from '../comment';
4+
import LoadingIndicator from '../../../../components/loading-indicator';
45

56
import type { GetAvatarUrlCallback, GetProfileUrlCallback } from '../../../common/flowTypes';
67
import type { Translations } from '../../flowTypes';
@@ -14,6 +15,7 @@ type Props = {
1415
getAvatarUrl: GetAvatarUrlCallback,
1516
getMentionWithQuery?: Function,
1617
getUserProfileUrl?: GetProfileUrlCallback,
18+
isRepliesLoading?: boolean,
1719
mentionSelectorContacts?: SelectorItems<>,
1820
onDelete?: Function,
1921
onEdit?: Function,
@@ -26,6 +28,7 @@ const ActivityThreadReplies = ({
2628
getAvatarUrl,
2729
getMentionWithQuery,
2830
getUserProfileUrl,
31+
isRepliesLoading,
2932
mentionSelectorContacts,
3033
onDelete,
3134
onEdit,
@@ -43,6 +46,11 @@ const ActivityThreadReplies = ({
4346

4447
return (
4548
<div className="bcs-ActivityThreadReplies" data-testid="activity-thread-replies">
49+
{isRepliesLoading && (
50+
<div className="bcs-ActivityThreadReplies-loading" data-testid="activity-thread-replies-loading">
51+
<LoadingIndicator />
52+
</div>
53+
)}
4654
{replies.map((reply: CommentType) => (
4755
<Comment
4856
key={`${reply.type}${reply.id}`}

src/elements/content-sidebar/activity-feed/activity-feed/ActivityThreadReplies.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@
1515
content: '';
1616
}
1717
}
18+
19+
.bcs-ActivityThreadReplies-loading {
20+
padding-bottom: $bdl-grid-unit * 5;
21+
}

src/elements/content-sidebar/activity-feed/activity-feed/__tests__/ActivityThread.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,11 @@ describe('src/elements/content-sidebar/activity-feed/activity-feed/ActivityThrea
8181
expect(queryByTestId('activity-thread-replies')).not.toBeInTheDocument();
8282
});
8383

84-
test('should render LoadingIndicator and do not render replies or button if repliesLoading is true', () => {
84+
test('should render LoadingIndicator and do not render button if repliesLoading is true', () => {
8585
const { queryByTestId } = getWrapper({ isRepliesLoading: true });
8686

87-
expect(queryByTestId('activity-thread-replies')).not.toBeInTheDocument();
8887
expect(queryByTestId('activity-thread-button')).not.toBeInTheDocument();
89-
expect(queryByTestId('activity-thread-loading')).toBeInTheDocument();
88+
expect(queryByTestId('activity-thread-replies-loading')).toBeInTheDocument();
9089
});
9190

9291
test('should NOT have reply button when onReplyCreate is not passed', () => {

src/elements/content-sidebar/activity-feed/activity-feed/__tests__/ActivityThreadReplies.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,16 @@ describe('src/elements/content-sidebar/activity-feed/activity-feed/ActivityThrea
1414
expect(queryByText(replies[1].message)).toBeVisible();
1515
expect(queryByText(replies[0].message)).toBeVisible();
1616
});
17+
18+
test('should render loading indicator if isRepliesLoading is true', () => {
19+
const { queryByTestId } = getWrapper({ isRepliesLoading: true });
20+
21+
expect(queryByTestId('activity-thread-replies-loading')).toBeInTheDocument();
22+
});
23+
24+
test('should not render loading indicator if isRepliesLoading is false', () => {
25+
const { queryByTestId } = getWrapper({ isRepliesLoading: false });
26+
27+
expect(queryByTestId('activity-thread-replies-loading')).not.toBeInTheDocument();
28+
});
1729
});

0 commit comments

Comments
 (0)