Skip to content

Commit 9d371c3

Browse files
committed
fix rendering bug with y/n confirm
1 parent 423688a commit 9d371c3

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.changeset/cyan-guests-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clack/core": patch
3+
---
4+
5+
Fix rendering bug when using y/n to confirm

packages/core/src/prompts/confirm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Prompt, { PromptOptions } from './prompt.js';
2-
2+
import { cursor } from 'sisteransi';
33

44
interface ConfirmOptions extends PromptOptions<ConfirmPrompt> {
55
active: string;
@@ -24,6 +24,7 @@ export default class ConfirmPrompt extends Prompt {
2424
})
2525

2626
this.on('confirm', (confirm) => {
27+
this.output.write(cursor.move(0, -1));
2728
this.value = confirm;
2829
this.state = 'submit';
2930
this.close()

packages/core/src/prompts/prompt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export interface PromptOptions<Self extends Prompt> {
4343
export type State = 'initial' | 'active' | 'cancel' | 'submit' | 'error';
4444

4545
export default class Prompt {
46-
private input: Readable;
47-
private output: Writable;
46+
protected input: Readable;
47+
protected output: Writable;
4848
private rl!: ReadLine;
4949
private opts: Omit<PromptOptions<Prompt>, 'render'|'input'|'output'>;
5050
private _track: boolean = false;

0 commit comments

Comments
 (0)