Skip to content

Commit 2e5c883

Browse files
authored
Merge pull request #458 from GetStream/fix-mention
fix: mention is duplicated #456
2 parents d9c0803 + 0f5c33c commit 2e5c883

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,25 @@ describe('AutocompleteTextareaComponent', () => {
272272
expect(userMentionSpy).toHaveBeenCalledWith([]);
273273
});
274274

275+
it('should update mentioned users after value is changed', () => {
276+
const userMentionSpy = jasmine.createSpy();
277+
component.userMentions.subscribe(userMentionSpy);
278+
component.autocompleteConfig.mentions![0].mentionSelect!(
279+
{
280+
user: { id: 'jack', name: 'Jack' },
281+
},
282+
'@'
283+
);
284+
285+
expect(userMentionSpy).toHaveBeenCalledWith([{ id: 'jack', name: 'Jack' }]);
286+
287+
component.value = '';
288+
userMentionSpy.calls.reset();
289+
component.ngOnChanges({ value: {} as SimpleChange });
290+
291+
expect(userMentionSpy).toHaveBeenCalledWith([]);
292+
});
293+
275294
it('should disable mentions if #areMentionsEnabled is false', () => {
276295
expect(component.autocompleteConfig.mentions!.length).toBe(2);
277296

projects/stream-chat-angular/src/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export class AutocompleteTextareaComponent
191191
}
192192
if (changes.value && !this.value && this.messageInput) {
193193
this.messageInput.nativeElement.style.height = 'auto';
194+
this.updateMentionedUsersFromText();
194195
}
195196
}
196197

0 commit comments

Comments
 (0)