Skip to content
Permalink
Browse files

fix(module:cascader): support falsy value expect for undefined and nu…

…ll (#4119)

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

* fix: tests

close #4110
  • Loading branch information...
wendzhue authored and hsuanxyz committed Sep 6, 2019
1 parent c530c74 commit 0cb44ac394d9730cad85d1b5d89bea0aa949ecd9
Showing with 10 additions and 4 deletions.
  1. +2 −2 components/cascader/nz-cascader.service.ts
  2. +8 −2 components/cascader/nz-cascader.spec.ts
@@ -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,
@@ -93,7 +93,7 @@ export class NzCascaderService implements OnDestroy {
const activatedOptionSetter = () => {
const currentValue = values[columnIndex];

if (!currentValue) {
if (!isNotNil(currentValue)) {
this.$redraw.next();
return;
}
@@ -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);
@@ -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);

0 comments on commit 0cb44ac

Please sign in to comment.
You can’t perform that action at this time.