fix(tui): reset question prompt edit state
This commit is contained in:
parent
331bed2469
commit
648ad90a41
1 changed files with 18 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { createStore } from "solid-js/store"
|
||||
import { createMemo, createSignal, For, onCleanup, onMount, Show } from "solid-js"
|
||||
import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show } from "solid-js"
|
||||
import { useRenderer } from "@opentui/solid"
|
||||
import type { TextareaRenderable } from "@opentui/core"
|
||||
import { selectedForeground, tint, useTheme } from "../../context/theme"
|
||||
|
|
@ -45,6 +45,21 @@ export function QuestionPrompt(props: { request: QuestionRequest }) {
|
|||
return store.answers[store.tab]?.includes(value) ?? false
|
||||
})
|
||||
|
||||
let requestID = props.request.id
|
||||
createEffect(() => {
|
||||
const next = props.request.id
|
||||
if (next === requestID) return
|
||||
requestID = next
|
||||
textarea = undefined
|
||||
setStore({
|
||||
tab: 0,
|
||||
answers: [],
|
||||
custom: [],
|
||||
selected: 0,
|
||||
editing: false,
|
||||
})
|
||||
})
|
||||
|
||||
function submit() {
|
||||
const answers = questions().map((_, i) => store.answers[i] ?? [])
|
||||
void sdk.client.question.reply({
|
||||
|
|
@ -95,8 +110,8 @@ export function QuestionPrompt(props: { request: QuestionRequest }) {
|
|||
}
|
||||
|
||||
function selectTab(index: number) {
|
||||
setStore("tab", index)
|
||||
setStore("selected", 0)
|
||||
textarea = undefined
|
||||
setStore({ tab: index, selected: 0, editing: false })
|
||||
}
|
||||
|
||||
function selectOption() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue