fix(ui): workflow editor fields no longer drop input (#1947)
This commit is contained in:
1 file changed
+4
-2
@@ -26,6 +26,8 @@ function edit(index: number, name: string, spec: Spec): void {
|
|||||||
// A rename to blank or onto another entry's name would drop an entry, so it is
|
// A rename to blank or onto another entry's name would drop an entry, so it is
|
||||||
// refused: the field goes back to the old name and says why.
|
// refused: the field goes back to the old name and says why.
|
||||||
const nameError = ref<{ index: number; message: string } | null>(null);
|
const nameError = ref<{ index: number; message: string } | null>(null);
|
||||||
|
// The input keeps what was typed; remounting the rows shows the kept name.
|
||||||
|
const resets = ref(0);
|
||||||
function rename(index: number, input: HTMLInputElement, spec: Spec): void {
|
function rename(index: number, input: HTMLInputElement, spec: Spec): void {
|
||||||
const name = input.value.trim();
|
const name = input.value.trim();
|
||||||
const current = list.value[index]?.[0] ?? "";
|
const current = list.value[index]?.[0] ?? "";
|
||||||
@@ -36,7 +38,7 @@ function rename(index: number, input: HTMLInputElement, spec: Spec): void {
|
|||||||
: "";
|
: "";
|
||||||
if (message) {
|
if (message) {
|
||||||
nameError.value = { index, message };
|
nameError.value = { index, message };
|
||||||
input.value = current;
|
resets.value++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nameError.value = null;
|
nameError.value = null;
|
||||||
@@ -57,7 +59,7 @@ function add(): void {
|
|||||||
<Button type="button" variant="ghost" size="xs" class="ml-auto" @click="add"><Plus data-icon="inline-start" />Add</Button>
|
<Button type="button" variant="ghost" size="xs" class="ml-auto" @click="add"><Plus data-icon="inline-start" />Add</Button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="list.length" class="divide-y divide-border rounded-md border border-border">
|
<div v-if="list.length" class="divide-y divide-border rounded-md border border-border">
|
||||||
<div v-for="([name, spec], i) in list" :key="i" class="px-2 py-1.5">
|
<div v-for="([name, spec], i) in list" :key="`${i}-${resets}`" class="px-2 py-1.5">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Input :model-value="name" class="h-8 min-w-0 flex-1 font-mono text-caption" :aria-label="`${field} name`" :aria-invalid="nameError?.index === i || undefined" @change="rename(i, $event.target as HTMLInputElement, spec)" />
|
<Input :model-value="name" class="h-8 min-w-0 flex-1 font-mono text-caption" :aria-label="`${field} name`" :aria-invalid="nameError?.index === i || undefined" @change="rename(i, $event.target as HTMLInputElement, spec)" />
|
||||||
<OptionSelect :model-value="spec.type ?? 'string'" :options="TYPES" class="w-24" :aria-label="`${name} type`" @update:model-value="edit(i, name, { ...spec, type: $event })" />
|
<OptionSelect :model-value="spec.type ?? 'string'" :options="TYPES" class="w-24" :aria-label="`${name} type`" @update:model-value="edit(i, name, { ...spec, type: $event })" />
|
||||||
|
|||||||
Reference in new issue
Block a user