Skip to content

Commit bc07a09

Browse files
committed
fix: stabilize popper components
1 parent ab597ef commit bc07a09

File tree

5 files changed

+13
-33
lines changed

5 files changed

+13
-33
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"@ngx-translate/core": "^13.0.0",
118118
"@ngx-translate/http-loader": "^6.0.0",
119119
"@popperjs/core": "^2.11.5",
120-
"@stream-io/stream-chat-css": "4.5.0",
120+
"@stream-io/stream-chat-css": "4.6.0",
121121
"@stream-io/transliterate": "^1.5.2",
122122
"angular-mentions": "^1.4.0",
123123
"dayjs": "^1.10.7",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<div
3636
class="str-chat__message-simple__actions str-chat__message-options"
3737
data-testid="message-options"
38+
[class.str-chat__message-actions-open]="isActionBoxOpen"
3839
[class.str-chat__message-edit-in-progress]="isEditing"
3940
*ngIf="areOptionsVisible"
4041
>
@@ -56,6 +57,7 @@
5657
[popperHideOnClickOutside]="true"
5758
[popperHideOnMouseLeave]="false"
5859
[popperDisableAnimation]="true"
60+
(popperOnHidden)="isActionBoxOpen = false"
5961
>
6062
<popper-content #popperContent>
6163
<ng-template

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -567,18 +567,6 @@ describe('MessageComponent', () => {
567567
});
568568
});
569569

570-
it('should close message actions box on mouseleave event', () => {
571-
component.enabledMessageActions = ['update-own-message', 'flag-message'];
572-
component.isActionBoxOpen = true;
573-
component.ngOnChanges({ enabledMessageActions: {} as SimpleChange });
574-
fixture.detectChanges();
575-
576-
queryContainer()?.dispatchEvent(new Event('mouseleave'));
577-
fixture.detectChanges();
578-
579-
expect(component.isActionBoxOpen).toBeFalse();
580-
});
581-
582570
it('should provide #enabledActions to message actions box', () => {
583571
component.isActionBoxOpen = true;
584572
fixture.detectChanges();

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ export class MessageComponent
161161
}
162162
if (isEditing !== this.isEditing) {
163163
this.isEditing = isEditing;
164+
if (!this.isEditing) {
165+
this.isActionBoxOpen = false;
166+
}
164167
if (this.isViewInited) {
165168
this.cdRef.detectChanges();
166169
}
@@ -257,11 +260,6 @@ export class MessageComponent
257260

258261
ngAfterViewInit(): void {
259262
this.isViewInited = true;
260-
this.ngZone.runOutsideAngular(() => {
261-
this.container?.nativeElement.addEventListener('mouseleave', () =>
262-
this.mouseLeft()
263-
);
264-
});
265263
}
266264

267265
ngOnDestroy(): void {
@@ -402,14 +400,6 @@ export class MessageComponent
402400
this.createMessageParts(false);
403401
}
404402

405-
mouseLeft() {
406-
if (this.isActionBoxOpen) {
407-
this.ngZone.run(() => {
408-
this.isActionBoxOpen = false;
409-
});
410-
}
411-
}
412-
413403
private createMessageParts(shouldTranslate = true) {
414404
this.messageTextParts = undefined;
415405
this.messageText = undefined;

0 commit comments

Comments
 (0)