Skip to content

Commit

Permalink
fix(module:cascader): support falsy value expect for undefined and nu…
Browse files Browse the repository at this point in the history
…ll (#4119)

* fix(module:cascader): support falsy value expect for undefined and null

* fix: tests

close #4110
  • Loading branch information
Wendell authored and hsuanxyz committed Sep 6, 2019
1 parent c530c74 commit 0cb44ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/cascader/nz-cascader.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { Injectable, OnDestroy } from '@angular/core';
import { BehaviorSubject, Subject } from 'rxjs';

import { arraysEqual } from 'ng-zorro-antd/core';
import { arraysEqual, isNotNil } from 'ng-zorro-antd/core';

import {
isShowSearchObject,
Expand Down Expand Up @@ -93,7 +93,7 @@ export class NzCascaderService implements OnDestroy {
const activatedOptionSetter = () => {
const currentValue = values[columnIndex];

if (!currentValue) {
if (!isNotNil(currentValue)) {
this.$redraw.next();
return;
}
Expand Down
10 changes: 8 additions & 2 deletions components/cascader/nz-cascader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,12 @@ describe('cascader', () => {
control.writeValue([]);
fixture.detectChanges();
expect(control.getSubmitValue().length).toBe(0);
control.writeValue(0);
fixture.detectChanges();
expect(control.getSubmitValue().length).toBe(1);
control.writeValue('');
fixture.detectChanges();
expect(control.getSubmitValue().length).toBe(0);
expect(control.getSubmitValue().length).toBe(1);
control.writeValue(['zhejiang']);
fixture.detectChanges();
expect(control.getSubmitValue().length).toBe(1);
Expand Down Expand Up @@ -660,9 +663,12 @@ describe('cascader', () => {
control.writeValue([]);
fixture.detectChanges();
expect(control.getSubmitValue().length).toBe(0);
control.writeValue(0);
fixture.detectChanges();
expect(control.getSubmitValue().length).toBe(1);
control.writeValue('');
fixture.detectChanges();
expect(control.getSubmitValue().length).toBe(0);
expect(control.getSubmitValue().length).toBe(1);
control.writeValue(['zhejiang']);
fixture.detectChanges();
expect(control.getSubmitValue().length).toBe(1);
Expand Down

0 comments on commit 0cb44ac

Please sign in to comment.