fix(ui): a host list inserted from the keyboard clipboard splits into separate egress hosts (#1967)
This commit is contained in:
1 file changed
+7
-1
@@ -91,6 +91,12 @@ const uptimeWarning = computed(() => {
|
||||
return `Shorter than ${limit}, so containers are killed before a task can finish.`;
|
||||
});
|
||||
|
||||
// A keyboard's clipboard inserts text as typing, not as a paste event, so a
|
||||
// pasted list arrives as one entry; split it here whatever the input path.
|
||||
function splitHosts(values: string[]): string[] {
|
||||
return [...new Set(values.flatMap((v) => v.split(/[\s,]+/)).filter(Boolean))];
|
||||
}
|
||||
|
||||
function formatHours(seconds: number): string {
|
||||
return seconds % 3600 === 0 ? `${seconds / 3600}h` : `${Math.round(seconds / 60)}m`;
|
||||
}
|
||||
@@ -363,7 +369,7 @@ function formatHours(seconds: number): string {
|
||||
add-on-blur
|
||||
add-on-paste
|
||||
:delimiter="/[\s,]+/"
|
||||
@update:model-value="(v) => field.handleChange(v as string[])"
|
||||
@update:model-value="(v) => field.handleChange(splitHosts(v as string[]))"
|
||||
>
|
||||
<TagsInputItem v-for="h in field.state.value ?? []" :key="h" :value="h">
|
||||
<TagsInputItemText />
|
||||
|
||||
Reference in new issue
Block a user