Skip to content

Commit

Permalink
fix(module:tabs): nzTabBarGutter is not work in vertical position (#…
Browse files Browse the repository at this point in the history
…5998)

close #5396
  • Loading branch information
hsuanxyz authored Nov 6, 2020
1 parent 50f0744 commit 516bf97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
21 changes: 17 additions & 4 deletions components/tabs/tabset.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,27 @@ describe('NzTabSet', () => {
expect(tabSetElement.classList).toContain('ant-tabs-editable-card');
});

it('should set the correct tabBarGutter', () => {
it('should set the correct tabBarGutterxxx', () => {
fixture.detectChanges();

const component = fixture.debugElement.componentInstance;
const tabsBtn = fixture.debugElement.queryAll(By.css('.ant-tabs-tab-btn'))!;
const tabsButtons = fixture.nativeElement.querySelectorAll('.ant-tabs-tab')! as HTMLElement[];
component.tabBarGutter = 10;
fixture.detectChanges();

tabsBtn.forEach(tab => {
expect(tab.nativeElement!.style.marginRight).toBe('10px');
expect(tabsButtons.length).toBe(3);

tabsButtons.forEach(tab => {
expect(tab.style.marginRight).toBe('10px');
expect(tab.style.marginBottom).toBe('');
});

component.position = 'left';
fixture.detectChanges();

tabsButtons.forEach(tab => {
expect(tab.style.marginRight).toBe('');
expect(tab.style.marginBottom).toBe('10px');
});
});

Expand Down
3 changes: 2 additions & 1 deletion components/tabs/tabset.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ let nextId = 0;
>
<div
class="ant-tabs-tab"
[style.margin-right.px]="position === 'horizontal' ? nzTabBarGutter : null"
[style.margin-bottom.px]="position === 'vertical' ? nzTabBarGutter : null"
[class.ant-tabs-tab-active]="nzSelectedIndex === i"
[class.ant-tabs-tab-disabled]="tab.nzDisabled"
(click)="clickNavItem(tab, i)"
Expand All @@ -87,7 +89,6 @@ let nextId = 0;
>
<div
role="tab"
[style.margin-right.px]="nzTabBarGutter"
[attr.tabIndex]="getTabIndex(tab, i)"
[attr.aria-disabled]="tab.nzDisabled"
[attr.aria-selected]="nzSelectedIndex === i && !nzHideAll"
Expand Down

0 comments on commit 516bf97

Please sign in to comment.