Skip to content

Commit

Permalink
fix(abc:notice-icon): fix nz-tabset animation triggers panel height
Browse files Browse the repository at this point in the history
- close #1804
  • Loading branch information
cipchk committed Jul 1, 2024
1 parent b9b36d6 commit a46ce08
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
16 changes: 9 additions & 7 deletions packages/abc/notice-icon/notice-icon.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
</div>
<nz-dropdown-menu #noticeMenu="nzDropdownMenu">
<nz-spin [nzSpinning]="loading" [nzDelay]="0">
<nz-tabset [nzSelectedIndex]="0" [nzCentered]="centered">
@for (i of data; track $index) {
<nz-tab [nzTitle]="i.title">
<notice-icon-tab [locale]="locale" [data]="i" (select)="onSelect($event)" (clear)="onClear($event)" />
</nz-tab>
}
</nz-tabset>
@if (delayShow) {
<nz-tabset [nzSelectedIndex]="0" [nzCentered]="centered">
@for (i of data; track $index) {
<nz-tab [nzTitle]="i.title">
<notice-icon-tab [locale]="locale" [data]="i" (select)="onSelect($event)" (clear)="onClear($event)" />
</nz-tab>
}
</nz-tabset>
}
</nz-spin>
</nz-dropdown-menu>
}
6 changes: 6 additions & 0 deletions packages/abc/notice-icon/notice-icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,14 @@ export class NoticeIconComponent implements OnInit, OnChanges, OnDestroy {
return `header-dropdown notice-icon${!this.centered ? ' notice-icon__tab-left' : ''}`;
}

delayShow = false;
onVisibleChange(result: boolean): void {
this.delayShow = result;
this.popoverVisibleChange.emit(result);
if (result) {
// Next tick run
Promise.resolve().then(() => this.cdr.detectChanges());
}
}

onSelect(i: NoticeIconSelect): void {
Expand Down
10 changes: 5 additions & 5 deletions packages/abc/notice-icon/notice-icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('abc: notice-icon', () => {
});
it('should be control loading in visible popover', done => {
context.loading = true;
context.popoverVisible = true;
context.comp.onVisibleChange(true);
fixture.detectChanges();
setTimeout(() => {
const el = document.querySelector('.ant-spin-container') as HTMLElement;
Expand All @@ -78,7 +78,7 @@ describe('abc: notice-icon', () => {
});
it('should be select item', done => {
spyOn(context, 'select');
context.popoverVisible = true;
context.comp.onVisibleChange(true);
fixture.detectChanges();
setTimeout(() => {
expect(context.select).not.toHaveBeenCalled();
Expand All @@ -90,7 +90,7 @@ describe('abc: notice-icon', () => {
});
it('should be clear', done => {
spyOn(context, 'clear');
context.popoverVisible = true;
context.comp.onVisibleChange(true);
fixture.detectChanges();
setTimeout(() => {
expect(context.clear).not.toHaveBeenCalled();
Expand All @@ -102,7 +102,7 @@ describe('abc: notice-icon', () => {
});
it('#centered', done => {
context.centered = true;
context.popoverVisible = true;
context.comp.onVisibleChange(true);
fixture.detectChanges();
setTimeout(() => {
expect(document.querySelectorAll('.notice-icon__tab-left').length).toBe(0);
Expand All @@ -112,7 +112,7 @@ describe('abc: notice-icon', () => {
});

it('#i18n', done => {
context.popoverVisible = true;
context.comp.onVisibleChange(true);
context.data = [{ title: 'a1', list: [] }];
fixture.detectChanges();
setTimeout(() => {
Expand Down

0 comments on commit a46ce08

Please sign in to comment.