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: retain number prompt default #1020

Merged
merged 1 commit into from Jun 15, 2021
Merged

fix: retain number prompt default #1020

merged 1 commit into from Jun 15, 2021

Conversation

tjallingt
Copy link
Contributor

The number prompt wants to use the default value if the input was invalid, however after a keypress (and if the default value is truthy) the default gets cleared. This is done so the default value is not rendered in the prompt anymore, see: #719

This PR changes the logic so that instead of clearing the default value it sets a new state called "touched". We can then use this state to hide the default value from the rendered prompt.

Updated the relevant test so it would have failed before.

@codecov
Copy link

codecov bot commented Jun 15, 2021

Codecov Report

Merging #1020 (2bc4808) into master (c4a3c23) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1020      +/-   ##
==========================================
+ Coverage   93.20%   93.28%   +0.08%     
==========================================
  Files          27       27              
  Lines        1163     1162       -1     
  Branches       25       25              
==========================================
  Hits         1084     1084              
+ Misses         79       78       -1     
Impacted Files Coverage Δ
packages/inquirer/lib/prompts/base.js 92.15% <100.00%> (ø)
packages/inquirer/lib/prompts/input.js 100.00% <100.00%> (+2.38%) ⬆️

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 c4a3c23...2bc4808. Read the comment docs.

@SBoudrias SBoudrias merged commit 73b6e65 into SBoudrias:master Jun 15, 2021
@SBoudrias
Copy link
Owner

Thanks!

@tjallingt tjallingt deleted the fix/number-prompt-default branch June 15, 2021 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants