Make interactive confirm optionally accept return key for confirmation
elfrucool opened this issue · comments
For some users, it is confusing that the interactive confirm component accepts their y
or n
answer immediately without requiring a confirmation through typing <enter>
key; this is specially true when adopting pterm
the first time.
It would be great to have something like pterm.DefaultInteractiveConfirm.WithWaitReturn(true).Show()
to enable this behavior.
(note: this feature request came from this question: #643 )
@elfrucool I've added a draft that includes this new functionality. Would you like to take a look and offer some feedback?
I'll take a look once I get a moment
Thanks for the feedback! I understand your point. Although, in situations where pressing Enter is associated with confirmation, it might be confusing if the default action is "No" or "Cancel".
Also, most CLI prompts don't include a "confirmation helper text", so it might not be necessary here.
In my view, removing the helper text seems like the better option. However, let's wait for the maintainers to decide if they prefer your suggestion (adds more complexity to the printer) or if it's best to remove "confirmation helper text" altogether.
@MarvinJWendt, could you please share your thoughts on this?
What I could imagine is this:
- New option in the
InteractiveConfirmPrinter
calledInstantSelect
- If
InstantSelect
istrue
: Pressing y or n will instantly confirm or abort the printer. - If
QuickSelect
isfalse
: Return is needed after pressing y or n to select- While Return is not pressed, the user should be able to switch between y or n
- If
InstantSelect
should betrue
inDefaultInteractiveConfirm
- That way, it can be disabled with
.WithInstantSelect(false)
.
- That way, it can be disabled with
Any objections? :)
I had a similar idea, and I agree with @elfrucool. It seems more logical to have it disabled by default. In my PR, I added a new option WithConfirmation(true)
to pterm.DefaultInteractiveConfirm
to enable the behavior of waiting for the user to confirm their answer by pressing . Of course, naming is subject to change. 😄
Any updates on this? Waiting on this since its a great feature that helps prevent confusion on how the interactive confirm works in sequence with other inputs, such as the select or text input, which both require "Enter"
@jcohen98 Hi, sorry for the late reply, apologies for the late reply. I've submitted a pull request and am now waiting for approval. I've explained my approach above and hope it will be merged soon.
Cheers!