Skip to content

Commit

Permalink
chore: fix related bugs (NG-ZORRO#3634)
Browse files Browse the repository at this point in the history
* fix(module:table): fix table sort default to ascend
close NG-ZORRO#3398

* fix(module:table): fix virtual scroll no data height
close NG-ZORRO#3419

* fix(module:table): fix table border error when small or bordered
close NG-ZORRO#3373 close NG-ZORRO#3032

* docs(module:table): fix table drag style

* fix(module:collapse): fix expand bug in Safari & animation bug
close NG-ZORRO#3098 close NG-ZORRO#3346
  • Loading branch information
vthinkxie authored and Ricbet committed Apr 9, 2020
1 parent ff46445 commit d101fc4
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 34 deletions.
9 changes: 5 additions & 4 deletions components/collapse/nz-collapse-panel.component.ts
Expand Up @@ -13,7 +13,6 @@ import {
ElementRef,
EventEmitter,
Host,
HostBinding,
Input,
OnDestroy,
OnInit,
Expand Down Expand Up @@ -42,12 +41,14 @@ import { NzCollapseComponent } from './nz-collapse.component';
`
],
host: {
'[class.ant-collapse-no-arrow]': '!nzShowArrow'
'[class.ant-collapse-no-arrow]': '!nzShowArrow',
'[class.ant-collapse-item-active]': 'nzActive',
'[class.ant-collapse-item-disabled]': 'nzDisabled'
}
})
export class NzCollapsePanelComponent implements OnInit, OnDestroy {
@Input() @InputBoolean() @HostBinding('class.ant-collapse-item-active') nzActive = false;
@Input() @InputBoolean() @HostBinding('class.ant-collapse-item-disabled') nzDisabled = false;
@Input() @InputBoolean() nzActive = false;
@Input() @InputBoolean() nzDisabled = false;
@Input() @InputBoolean() nzShowArrow = true;
@Input() nzExtra: string | TemplateRef<void>;
@Input() nzHeader: string | TemplateRef<void>;
Expand Down
2 changes: 1 addition & 1 deletion components/core/animation/collapse.ts
Expand Up @@ -12,7 +12,7 @@ import { AnimationCurves } from './animation-consts';
export const collapseMotion: AnimationTriggerMetadata = trigger('collapseMotion', [
state('expanded', style({ height: '*' })),
state('collapsed', style({ height: 0, overflow: 'hidden' })),
state('hidden', style({ height: 0, display: 'none' })),
state('hidden', style({ height: 0, overflow: 'hidden', borderTopWidth: '0' })),
transition('expanded => collapsed', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('expanded => hidden', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('collapsed => expanded', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
Expand Down
3 changes: 2 additions & 1 deletion components/table/nz-table.component.html
Expand Up @@ -40,6 +40,7 @@
<ng-template #scrollViewTpl>
<cdk-virtual-scroll-viewport
class="ant-table-body"
[hidden]="!data.length"
[itemSize]="nzVirtualItemSize"
[maxBufferPx]="nzVirtualMaxBufferPx"
[minBufferPx]="nzVirtualMinBufferPx"
Expand Down Expand Up @@ -70,7 +71,7 @@
[nzShowQuickJumper]="nzShowQuickJumper"
[nzHideOnSinglePage]="nzHideOnSinglePage"
[nzShowTotal]="nzShowTotal"
[nzSize]="(nzSize === 'middle' || nzSize=='small') ? 'small' : ''"
[nzSize]="nzSize === 'default' ? 'default' : 'small'"
[nzPageSize]="nzPageSize"
[nzTotal]="nzTotal"
[nzSimple]="nzSimple"
Expand Down
10 changes: 4 additions & 6 deletions components/table/nz-table.component.ts
Expand Up @@ -205,20 +205,18 @@ export class NzTableComponent<T = any> implements OnInit, AfterViewInit, OnDestr
}

updateFrontPaginationDataIfNeeded(isPageSizeOrDataChange: boolean = false): void {
let data: any[] = []; // tslint:disable-line:no-any
let data = this.nzData || [];
if (this.nzFrontPagination) {
this.nzTotal = this.nzData.length;
this.nzTotal = data.length;
if (isPageSizeOrDataChange) {
const maxPageIndex = Math.ceil(this.nzData.length / this.nzPageSize) || 1;
const maxPageIndex = Math.ceil(data.length / this.nzPageSize) || 1;
const pageIndex = this.nzPageIndex > maxPageIndex ? maxPageIndex : this.nzPageIndex;
if (pageIndex !== this.nzPageIndex) {
this.nzPageIndex = pageIndex;
Promise.resolve().then(() => this.nzPageIndexChange.emit(pageIndex));
}
}
data = this.nzData.slice((this.nzPageIndex - 1) * this.nzPageSize, this.nzPageIndex * this.nzPageSize);
} else {
data = this.nzData;
data = data.slice((this.nzPageIndex - 1) * this.nzPageSize, this.nzPageIndex * this.nzPageSize);
}
this.data = [...data];
this.nzCurrentPageDataChange.next(this.data);
Expand Down
4 changes: 2 additions & 2 deletions components/table/nz-th.component.html
Expand Up @@ -30,8 +30,8 @@
</div>
<ng-content></ng-content>
</span>
<ng-content selector="[nz-dropdown]"></ng-content>
<ng-content selector="nz-dropdown"></ng-content>
<ng-content select="[nz-dropdown]"></ng-content>
<ng-content select="nz-dropdown"></ng-content>
<div class="ant-table-column-sorter" *ngIf="nzShowSort">
<div class="ant-table-column-sorter-inner ant-table-column-sorter-inner-full">
<i nz-icon
Expand Down
8 changes: 4 additions & 4 deletions components/table/nz-th.component.ts
Expand Up @@ -97,12 +97,12 @@ export class NzThComponent implements OnChanges, OnInit, OnDestroy {

updateSortValue(): void {
if (this.nzShowSort) {
if (this.nzSort === 'descend') {
this.setSortValue('ascend');
} else if (this.nzSort === 'ascend') {
if (this.nzSort === 'ascend') {
this.setSortValue('descend');
} else if (this.nzSort === 'descend') {
this.setSortValue(null);
} else {
this.setSortValue('descend');
this.setSortValue('ascend');
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions components/table/nz-th.spec.ts
Expand Up @@ -136,16 +136,16 @@ describe('nz-th', () => {
expect(th.nativeElement.querySelector('.ant-table-column-sorter-down').classList).toContain('off');
th.nativeElement.querySelector('.ant-table-column-sorters').firstElementChild.click();
fixture.detectChanges();
expect(testComponent.sort).toBe('descend');
expect(testComponent.sort).toBe('ascend');
expect(testComponent.sortChange).toHaveBeenCalledTimes(1);
expect(th.nativeElement.querySelector('.ant-table-column-sorter-up').classList).toContain('off');
expect(th.nativeElement.querySelector('.ant-table-column-sorter-down').classList).toContain('on');
expect(th.nativeElement.querySelector('.ant-table-column-sorter-up').classList).toContain('on');
expect(th.nativeElement.querySelector('.ant-table-column-sorter-down').classList).toContain('off');
th.nativeElement.querySelector('.ant-table-column-sorters').firstElementChild.click();
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(2);
expect(testComponent.sort).toBe('ascend');
expect(th.nativeElement.querySelector('.ant-table-column-sorter-up').classList).toContain('on');
expect(th.nativeElement.querySelector('.ant-table-column-sorter-down').classList).toContain('off');
expect(testComponent.sort).toBe('descend');
expect(th.nativeElement.querySelector('.ant-table-column-sorter-up').classList).toContain('off');
expect(th.nativeElement.querySelector('.ant-table-column-sorter-down').classList).toContain('on');
th.nativeElement.querySelector('.ant-table-column-sorters').firstElementChild.click();
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(3);
Expand Down
10 changes: 5 additions & 5 deletions components/table/nz-thead.spec.ts
Expand Up @@ -32,11 +32,11 @@ describe('nz-thead', () => {
upButtons[0].click();
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(1);
expect(upButtons[0].querySelector('.ant-table-column-sorter-down').classList).toContain('on');
expect(upButtons[0].querySelector('.ant-table-column-sorter-down').classList).toContain('off');
upButtons[1].click();
fixture.detectChanges();
expect(upButtons[0].querySelector('.ant-table-column-sorter-down').classList).toContain('on');
expect(upButtons[1].querySelector('.ant-table-column-sorter-down').classList).toContain('on');
expect(upButtons[0].querySelector('.ant-table-column-sorter-down').classList).toContain('off');
expect(upButtons[1].querySelector('.ant-table-column-sorter-down').classList).toContain('off');
expect(testComponent.sortChange).toHaveBeenCalledTimes(2);
});
it('should singleSort change', () => {
Expand All @@ -47,11 +47,11 @@ describe('nz-thead', () => {
upButtons[0].click();
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(1);
expect(upButtons[0].querySelector('.ant-table-column-sorter-down').classList).toContain('on');
expect(upButtons[0].querySelector('.ant-table-column-sorter-down').classList).toContain('off');
upButtons[1].click();
fixture.detectChanges();
expect(upButtons[0].querySelector('.ant-table-column-sorter-down').classList).toContain('off');
expect(upButtons[1].querySelector('.ant-table-column-sorter-down').classList).toContain('on');
expect(upButtons[1].querySelector('.ant-table-column-sorter-down').classList).toContain('off');
expect(testComponent.sortChange).toHaveBeenCalledTimes(2);
});

Expand Down
25 changes: 22 additions & 3 deletions components/table/style/patch.less
Expand Up @@ -39,8 +39,8 @@ nz-table {
}

.border-right() {
.@{table-th-left-cls}-sticky,
.@{table-td-left-cls}-sticky {
tr > th:first-child.@{table-th-left-cls}-sticky,
tr > td:first-child.@{table-td-left-cls}-sticky {
border-left: @border-width-base @border-style-base @border-color-split;
}
}
Expand All @@ -56,6 +56,14 @@ nz-table {
}
}

.@{table-prefix-cls}-scroll-position-middle,
.@{table-prefix-cls}-scroll-position-right {
table {
&.@{table-prefix-cls}-fixed {
border-left: none;
}
}
}

.@{table-th-left-cls}-sticky,
.@{table-th-right-cls}-sticky,
Expand Down Expand Up @@ -103,7 +111,7 @@ nz-table {
.box-shadow-right;
}

.@{table-prefix-cls}-bordered {
.@{table-prefix-cls}-bordered:not(.@{table-prefix-cls}-small) {
&.@{table-prefix-cls}-scroll-position-middle {
.border-right;
.border-left;
Expand Down Expand Up @@ -131,6 +139,17 @@ nz-table {
}

.@{table-prefix-cls}-small {
&.@{table-prefix-cls}-bordered {
.@{table-prefix-cls}-thead > tr > th:last-child,
.@{table-prefix-cls}-tbody > tr > td:last-child {
border-right: @border-width-base @border-style-base @border-color-split;
}
.@{table-prefix-cls}-thead > tr:first-child > th:last-child,
.@{table-prefix-cls}-tbody > tr:first-child > td:last-child {
border-right: none;
}
}

> .@{table-prefix-cls}-content {
> .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-header > table,
> .@{table-prefix-cls}-scroll > .@{table-prefix-cls}-body > table,
Expand Down
4 changes: 3 additions & 1 deletion components/upload/nz-upload-btn.component.ts
Expand Up @@ -72,7 +72,9 @@ export class NzUploadBtnComponent implements OnInit, OnChanges, OnDestroy {

@HostListener('drop', ['$event'])
@HostListener('dragover', ['$event'])
onFileDrop(e: DragEvent): void {
// skip safari bug
// tslint:disable-next-line:no-any
onFileDrop(e: any): void {
if (this.options.disabled || e.type === 'dragover') {
e.preventDefault();
return;
Expand Down
4 changes: 3 additions & 1 deletion components/upload/nz-upload.component.ts
Expand Up @@ -244,7 +244,9 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy {

private dragState: string;

fileDrop(e: DragEvent): void {
// skip safari bug
// tslint:disable-next-line:no-any
fileDrop(e: any): void {
if (e.type === this.dragState) {
return;
}
Expand Down

0 comments on commit d101fc4

Please sign in to comment.