-
Notifications
You must be signed in to change notification settings - Fork 161
fix: use placeholder as value when input is empty #263
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
Conversation
🦋 Changeset detectedLatest commit: bc1c865 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
im not sure this is right 🤔
edit: ignore me on this bit. the placeholder is basically a default value you can do you have an example of how you're using it? i.e. how you produced whats in the screenshot |
|
@43081j Thanks for your review! The following is an example that uses the code from https://bomb.sh/docs/basics/getting-started/#quick-start directly. 2025-04-02.8.29.22.movHere is how the Vite CLI works. 2025-04-02.8.33.14.movThe Astro CLI is: 2025-04-02.8.39.08.movActually, it looks like Vite CLI uses the prompts package, but its behavior is different, haha. |
|
ok i understand now 👍 i think we should fix this in the core rather than specifically in the text prompt basically, if you press the problem seems to be that if you don't tab it in, and just press enter, it doesn't actually set the value. so we should probably update the core |
|
@43081j Thanks for great review. I've updated the core to behave as follows when there is no input value: First and foremost, set the default value as the value. |
dreyfus92
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first of all thank you @jsparkdev, for taking the time and taking a look at this. this solution might work in some cases, but i think it might have some limitations that could lead into more issues, like ambiguity with falsy values e.g. if opts.defaultValue is an empty string (''), it skips to opts.placeholder, which might not be the desired behavior if an empty string is a valid default value. also we might face type safety issues, this assumes that opts.defaulValue and opts.placeholder are either strings or falsy, if the could be other types, the result might be unexpected or inconsistent. what about if we try something else? i haven't tested this myself. cc @43081j
|
i don't think it belongs in the text prompt in clack/packages/core/src/prompts/prompt.ts Lines 197 to 202 in 041e13c
i feel like we should just check here for then later, we handle submission etc because return was pressed |
text function to fixing bug|
@example/basic • @example/changesets commit: |
natemoo-re
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see you here, thanks so much for the PR! 🎉
Co-authored-by: Nate Moore <[email protected]>
Fix a bug where the placeholder value is not used when no value is provided to the
textfunction.before:
After:
