Skip to content

Commit 8d43dfa

Browse files
committed
feat: Add message options trigger input to message list
1 parent 1a24031 commit 8d43dfa

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

projects/stream-chat-angular/src/lib/message-list/message-list.component.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
(scroll)="scrolled()"
66
>
77
<div class="str-chat__reverse-infinite-scroll str-chat__message-list-scroll">
8-
<ul class="str-chat__ul">
8+
<ul
9+
class="str-chat__ul"
10+
[class.str-chat__message-options-in-bubble]="
11+
messageOptionsTrigger === 'message-bubble'
12+
"
13+
>
914
<li
1015
#parentMessageElement
1116
*ngIf="mode === 'thread'"

projects/stream-chat-angular/src/lib/message-list/message-list.component.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,4 +910,21 @@ describe('MessageListComponent', () => {
910910
expect(queryLoadingIndicator('top')).not.toBeNull();
911911
expect(queryLoadingIndicator('bottom')).toBeNull();
912912
});
913+
914+
it('should add/rome CSS class based on #messageOptionsTrigger input', () => {
915+
expect(
916+
fixture.nativeElement.querySelector(
917+
'.str-chat__message-options-in-bubble'
918+
)
919+
).toBeNull();
920+
921+
component.messageOptionsTrigger = 'message-bubble';
922+
fixture.detectChanges();
923+
924+
expect(
925+
fixture.nativeElement.querySelector(
926+
'.str-chat__message-options-in-bubble'
927+
)
928+
).not.toBeNull();
929+
});
913930
});

projects/stream-chat-angular/src/lib/message-list/message-list.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export class MessageListComponent
4646
* The direction of the messages in the list, `bottom-to-top` means newest message is at the bottom of the message list and users scroll upwards to load older messages
4747
*/
4848
@Input() direction: 'bottom-to-top' | 'top-to-bottom' = 'bottom-to-top';
49+
/**
50+
* Determines what triggers the appearance of the message options: by default you can hover (click on mobile) anywhere in the row of the message (`message-row` option), or you can set `message-bubble`, in that case only a hover (click on mobile) in the message bubble will trigger the options to appear.
51+
*/
52+
@Input() messageOptionsTrigger: 'message-row' | 'message-bubble' =
53+
'message-row';
4954
typingIndicatorTemplate: TemplateRef<TypingIndicatorContext> | undefined;
5055
messageTemplate: TemplateRef<MessageContext> | undefined;
5156
messages$!: Observable<StreamMessage[]>;

0 commit comments

Comments
 (0)