Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 229acd5

Browse files
committed
Render the "add emoji" button when no reaction groups are present
1 parent 1570afe commit 229acd5

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lib/views/emoji-reactions-view.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ export class BareEmojiReactionsView extends React.Component {
4444
const viewerReacted = this.props.reactable.reactionGroups
4545
.filter(group => group.viewerHasReacted)
4646
.map(group => group.content);
47-
const emptyGroupExists = this.props.reactable.reactionGroups
48-
.some(g => g.users.totalCount === 0);
47+
const {reactionGroups} = this.props.reactable;
48+
const showAddButton = reactionGroups.length === 0 || reactionGroups.some(g => g.users.totalCount === 0);
4949

5050
return (
5151
<div className="github-EmojiReactions btn-toolbar">
52-
{emptyGroupExists && (
52+
{showAddButton && (
5353
<div className="btn-group">
5454
<button
5555
className="github-EmojiReactions-add btn icon icon-smiley"

test/views/emoji-reactions-view.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ describe('EmojiReactionsView', function() {
118118
assert.isTrue(wrapper.find(ReactionPickerController).exists());
119119
});
120120

121+
it('displays an "add emoji" control when no reaction groups are present', function() {
122+
// This happens when the Reactable is optimistically rendered.
123+
const reactable = issueBuilder(reactableQuery).build();
124+
125+
const wrapper = shallow(buildApp({reactable}));
126+
assert.isTrue(wrapper.exists('.github-EmojiReactions-add'));
127+
assert.isTrue(wrapper.find(ReactionPickerController).exists());
128+
});
129+
121130
it('does not display the "add emoji" control if all reaction groups are nonempty', function() {
122131
const reactable = issueBuilder(reactableQuery)
123132
.addReactionGroup(group => group.content('THUMBS_UP').users(u => u.totalCount(1)))

0 commit comments

Comments
 (0)