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

polish: accept Enter as a valid key in confirm dialogs #887

Merged
merged 1 commit into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/tasty-pets-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

polish: accept Enter as a valid key in confirm dialogs

Instead of logging "Unrecognised input" when hitting return/enter in a confirm dialog, we should accept it as a confirmation. This patch also makes the default choice "y" bold in the dialog.
9 changes: 6 additions & 3 deletions packages/wrangler/src/dialogs.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chalk from "chalk";
import { Box, Text, useInput, render } from "ink";
import TextInput from "ink-text-input";
import * as React from "react";
Expand All @@ -8,8 +9,8 @@ type ConfirmProps = {
onConfirm: (answer: boolean) => void;
};
function Confirm(props: ConfirmProps) {
useInput((input: string) => {
if (input === "y") {
useInput((input: string, key) => {
if (input === "y" || key.return === true) {
props.onConfirm(true);
} else if (input === "n") {
props.onConfirm(false);
Expand All @@ -19,7 +20,9 @@ function Confirm(props: ConfirmProps) {
});
return (
<Box>
<Text>{props.text} (y/n) </Text>
<Text>
{props.text} ({chalk.bold("y")}/n)
</Text>
</Box>
);
}
Expand Down