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

fix(module:select): accept 0 value on enter #5904

Merged

Conversation

vazgen6
Copy link
Contributor

@vazgen6 vazgen6 commented Oct 12, 2020

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[x] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

When using nz-select component with an option where [nzValue]="0" and hitting enter the value is not being saved, because this.activatedValue = 0 and it is a falsy value thus not entering the if block to call the onItemClick method.

Issue Number: N/A

What is the new behavior?

Optional @input() was added to solve this problem. By passing [nzAcceptZeroValue]="true" to NzSelectComponent

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

I don't know Chinese the Chinese docs were Google translated.

@zorro-bot
Copy link

zorro-bot bot commented Oct 12, 2020

This preview will be available after the AzureCI is passed.

@vazgen6 vazgen6 force-pushed the feat/nz-select-accept-0-values-on-enter branch from d764b1c to b5c2d03 Compare October 12, 2020 19:14
@codecov
Copy link

codecov bot commented Oct 12, 2020

Codecov Report

Merging #5904 into master will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5904      +/-   ##
==========================================
- Coverage   90.02%   90.01%   -0.02%     
==========================================
  Files         463      463              
  Lines       13946    13946              
  Branches     2201     2201              
==========================================
- Hits        12555    12553       -2     
- Misses        857      859       +2     
  Partials      534      534              
Impacted Files Coverage Δ
components/select/select.component.ts 87.67% <0.00%> (ø)
components/tabs/tab-nav-bar.component.ts 80.91% <0.00%> (-1.42%) ⬇️
components/core/util/text-measure.ts 91.30% <0.00%> (+1.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b5fdee...6a3213c. Read the comment docs.

@hsuanxyz
Copy link
Member

@vthinkxie I think it's a bug, if 0 is valid value, it should also be handled correctly by the keyboard.

@hsuanxyz
Copy link
Member

@vazgen6 Thanks for the PR, no need to a new input here, just correct judgement!

+ import { isNotNil } from 'ng-zorro-antd/core/util';

- if (this.activatedValue)
+ if (isNotNil(this.activatedValue))

@vthinkxie
Copy link
Member

Hi @vazgen6
thanks for your PR, I agree with @hsuanxyz
could you update your PR following @hsuanxyz 's suggestion?

@vazgen6
Copy link
Contributor Author

vazgen6 commented Oct 13, 2020

@vazgen6 Thanks for the PR, no need to a new input here, just correct judgement!

+ import { isNotNil } from 'ng-zorro-antd/core/util';

- if (this.activatedValue)
+ if (isNotNil(this.activatedValue))

I also agree with this, initially I thought doing something similar but was afraid to break existing behavior but since user can click on it they should be able to use enter to select too.

@vazgen6
Copy link
Contributor Author

vazgen6 commented Oct 13, 2020

could you update your PR following @hsuanxyz 's suggestion?

Sure thing, I will update it asap.

@vazgen6
Copy link
Contributor Author

vazgen6 commented Oct 13, 2020

@vthinkxie I think it's a bug, if 0 is valid value, it should also be handled correctly by the keyboard.

@hsuanxyz If this is a bug, should I update my commit message? Or let me know what is more accepted, if I amend with new message and force push will it cause any problems for you?

@hsuanxyz
Copy link
Member

@vthinkxie I think it's a bug, if 0 is valid value, it should also be handled correctly by the keyboard.

@hsuanxyz If this is a bug, should I update my commit message? Or let me know what is more accepted, if I amend with new message and force push will it cause any problems for you?

no problem, you can --amend and --force .

@vazgen6 vazgen6 force-pushed the feat/nz-select-accept-0-values-on-enter branch from b5c2d03 to c9a23e1 Compare October 13, 2020 06:31
@vazgen6 vazgen6 force-pushed the feat/nz-select-accept-0-values-on-enter branch from c9a23e1 to 6a3213c Compare October 13, 2020 06:35
@vazgen6
Copy link
Contributor Author

vazgen6 commented Oct 13, 2020

@vthinkxie I think it's a bug, if 0 is valid value, it should also be handled correctly by the keyboard.

@hsuanxyz If this is a bug, should I update my commit message? Or let me know what is more accepted, if I amend with new message and force push will it cause any problems for you?

no problem, you can --amend and --force .

Done! I just fetched from upstream and rebased. Please let me know if there's something else I can do and thank you for your quick reply and support.

@hsuanxyz
Copy link
Member

👏 That's right. We'll merge it when @vthinkxie is done reviewing.

Copy link
Member

@vthinkxie vthinkxie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good job

@hsuanxyz hsuanxyz changed the title feat(module:select): accept 0 value on enter fix(module:select): accept 0 value on enter Oct 13, 2020
@vthinkxie vthinkxie merged commit 574fdf0 into NG-ZORRO:master Oct 13, 2020
@github-actions
Copy link

github-actions bot commented Oct 13, 2020

😭 Deploy PR Preview 574fdf0 failed. Build logs

🤖 By surge-preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants