Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(input-number) 当按 tab 切换时无法校验,以及 #203

Closed
cipchk opened this issue Aug 31, 2017 · 4 comments · Fixed by #230
Closed

bug(input-number) 当按 tab 切换时无法校验,以及 #203

cipchk opened this issue Aug 31, 2017 · 4 comments · Fixed by #230
Labels

Comments

@cipchk
Copy link
Member

cipchk commented Aug 31, 2017

I'm submitting a...


[x] Bug report  

Current behavior

<nz-input-number [(ngModel)]="demoValue" name="demoValue" [nzMin]="1" [nzMax]="10" [nzStep]="1"></nz-input-number>

会有两个问题:

  • 若初始值 demoValue=11 “减” 的状态不正确。
  • 文本框录入 1000 按下 Tab 键时依然是 1000 2

晚安!

@cipchk cipchk changed the title [input-number] 当按 tab 切换时无法校验,以及 bug(input-number) 当按 tab 切换时无法校验,以及 Aug 31, 2017
@standbyme
Copy link
Contributor

+1

@create-share
Copy link
Contributor

I think _checkDisabled call the wrong location.

https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/src/components/input-number/nz-input-number.component.ts#L168

export class NzInputNumberComponent implements ControlValueAccessor {
  // ...
  set nzValue(value: number) {
    if (this._value === value) {
      return;
    }
    if (value > this.nzMax) {
      this._value = this.nzMax;
      this.onChange(this.nzMax);
    } else if (value < this.nzMin) {
      this._value = this.nzMin;
      this.onChange(this.nzMin);
    } else {
      this._value = value;
      this._checkDisabled(); // disabled should be called after the setter function instead of here
    }
  }
}

@vthinkxie
Copy link
Member

confirm, thanks for feedback.

@lock
Copy link

lock bot commented Feb 19, 2019

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants