[feature] automatically set prompt to edit default without pressing tab
When setting a default on an input prompt you can "press tab to inline the value for edits".
I would like this behavior to happen automatically without having to press tab.
This could be done with an extra option called inlineDefault: boolean or similar.
link to original tab feature request: #1215
Interface wise, I think it'd be cleaner to have a different prop name like value or prefill or something like this. And make default or this key exclusive in the TS types.
Hey @SBoudrias long time user, first time contributor. I'd like to tackle this one.
Is there a preconceived way of implementing this feature already? Are you aware of potentially any traps or pitfalls around this area?
Proposed Implementation
// BWC behaviour prefill 'tab' (or omitted will allow the user to prefill the text with the default value for editing'
input({
message: "Choose a username",
default: 'SBoudrias',
prefill: 'tab' // Or omit (under the hood 'tab' is the default)
})
// New behaviour, when prefill is set to 'always' it will populate the input field with the default value so the user can edit and submit
input({
message: "Choose a username",
default: 'SBoudrias',
prefill: 'always' // will always set the initial value of the input with the default value.
})
// The prefill prop does nothing when default is not set
input({
message: "Choose a username",
prefill: 'always' // Does nothing
})
input({
message: "Choose a username",
prefill: 'tab' // Does nothing
})
I'll make sure to update the documentation to explain this behaviour.
Please let me know if this aligns and I'll whip up a PR.
Hey @wannabewayno contribution welcomed! And I like the approach.
Let's just rename 'always' to 'editable' or 'inline' I think? I don't feel always properly communicate the behavior.
I like the 'editable' suggestion, much clearer. Thanks!