Skip to content

[Bug] [Regression] Text Prompt Incorrectly Uses Placeholder Value as the Default Value #322

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

Closed
aliasghar98 opened this issue May 17, 2025 · 10 comments
Labels
bug Something isn't working

Comments

@aliasghar98
Copy link

aliasghar98 commented May 17, 2025

Environment

  • OS: Windows
  • Node Version: 18.20.4
  • Package: @clack/prompts
  • Package Version: 0.10.1

Describe the bug
Upon not entering anything for a text prompt and having a placeholder value defined, the placeholder value replaces the actual text input for that prompt twice duplicated.

To Reproduce
Please refer to the screenshots.

Image

Image

Image

@aliasghar98 aliasghar98 added the bug Something isn't working label May 17, 2025
@github-project-automation github-project-automation bot moved this to Needs triage in Triage Board May 17, 2025
@manuel3108
Copy link

I think this is describes the same problem as in #321, although this issue focuses on 0.x packages whereas #321 is for 1.0 alpha

@43081j
Copy link
Collaborator

43081j commented May 20, 2025

i don't understand how you managed to get the value twice. what exactly did you do? did you press tab? return? etc

the exact steps you made to get there would be helpful.

meanwhile, there was a change to make the placeholder insert when you press enter. i think we probably shouldn't have made that change.

@natemoo-re @dreyfus92 i think the right move here is to revert 5dfce8a in 0.x until we can figure out what behaviour we want

@aliasghar98
Copy link
Author

aliasghar98 commented May 20, 2025

@43081j I pressed Enter/Return like I mentioned in the placeholder. That gave me the value twice.

@43081j
Copy link
Collaborator

43081j commented May 20, 2025

i can't seem to reproduce that locally

in 0.x with this:

const result = await prompts.text({
  message: 'hi',
  placeholder: 'bleep',
  defaultValue: 'bloop'
});
// result is bleep

as in, i do get the placeholder and we should fix that. but i can't get it to repeat the value

@aliasghar98
Copy link
Author

aliasghar98 commented May 21, 2025

@43081j Yes you're right, I wasn't able to reproduce the repetition of the value for version 0.10.0 and below. Seems like it only happens for 0.10.1 and above. I have updated the issue to reflect this. Thanks for looking into it!

Moving forward, are you guys planning on using the placeholder as the value of result in your example if nothing was entered? If yes, I'd have to rethink things on my end.

@aliasghar98
Copy link
Author

@43081j Here's how to reproduce the bug: https://stackblitz.com/edit/node-yermlvhc?file=package.json,index.js . Looks like there are two issues here:

  1. The placeholder value problem.
  2. The validate function duplicating the placeholder value.

@43081j
Copy link
Collaborator

43081j commented May 21, 2025

I have to get agreement from the other maintainers but I'd like to make placeholder a visual thing rather than ever being used as a value

Meanwhile I think we will roll back the change in 0.x that caused this either way

@43081j
Copy link
Collaborator

43081j commented May 21, 2025

@aliasghar98 can you try out the pkg.pr install in #324 and let me know if it fixes both issues

@aliasghar98
Copy link
Author

@43081j Just tried it out, works perfectly fine. Thanks!

@43081j
Copy link
Collaborator

43081j commented May 22, 2025

this has now been released 🎉

let me know if there's any problems, but otherwise closing this now 👍

@43081j 43081j closed this as completed May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Needs triage
Development

No branches or pull requests

3 participants