From 809d23245f806ab0117f57f01027b33ebdc84f03 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 3 Jul 2025 23:29:36 +0200 Subject: [PATCH] The prompt confirmation system wasn't really working after moving to lexical The async value setting was biting us here --- app/javascript/controllers/terminal_controller.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/javascript/controllers/terminal_controller.js b/app/javascript/controllers/terminal_controller.js index aa857479b..35681f97c 100644 --- a/app/javascript/controllers/terminal_controller.js +++ b/app/javascript/controllers/terminal_controller.js @@ -162,13 +162,15 @@ export default class extends Controller { this.waitingForConfirmationValue = true } - #showConfirmationPrompt(confirmationPrompt) { + async #showConfirmationPrompt(confirmationPrompt) { if (isMultiLineString(confirmationPrompt)) { this.#showOutput(confirmationPrompt) this.inputTarget.value = `Apply these changes? [Y/n] ` } else { this.inputTarget.value = `${confirmationPrompt}? [Y/n] ` } + + await nextFrame() } #handleConfirmationKey(key) { @@ -180,16 +182,17 @@ export default class extends Controller { } } - #submitWithConfirmation() { + async #submitWithConfirmation() { this.inputTarget.value = this.originalInputValue this.confirmationTarget.value = "confirmed" this.#hideOutput() + + await nextFrame() this.#submitCommand() } #submitCommand() { this.formTarget.requestSubmit() - this.#reset() } #showOutput(markdown) {