fix: newDownload was causing infinite loop when switching to mulit url mode
This commit is contained in:
parent
03cabe6c70
commit
716fce8941
1 changed files with 13 additions and 19 deletions
|
|
@ -37,7 +37,6 @@
|
||||||
base: 'min-h-[7.25rem] bg-elevated/60 ring-default focus-visible:ring-primary',
|
base: 'min-h-[7.25rem] bg-elevated/60 ring-default focus-visible:ring-primary',
|
||||||
}"
|
}"
|
||||||
@keydown="handleKeyDown"
|
@keydown="handleKeyDown"
|
||||||
@input="() => void adjustTextareaHeight()"
|
|
||||||
/>
|
/>
|
||||||
<UInput
|
<UInput
|
||||||
v-else
|
v-else
|
||||||
|
|
@ -662,9 +661,10 @@ const is_valid_dl_field = (dl_field: string): boolean => {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const adjustTextareaHeight = async (): Promise<void> => {
|
const getUrlElement = (): HTMLInputElement | HTMLTextAreaElement | null => {
|
||||||
await nextTick();
|
return (
|
||||||
urlTextarea.value?.textareaRef?.dispatchEvent(new Event('input', { bubbles: true }));
|
urlTextarea.value?.textareaRef || (document.getElementById('url') as HTMLInputElement | null)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKeyDown = async (event: KeyboardEvent): Promise<void> => {
|
const handleKeyDown = async (event: KeyboardEvent): Promise<void> => {
|
||||||
|
|
@ -690,10 +690,10 @@ const handleKeyDown = async (event: KeyboardEvent): Promise<void> => {
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
if (urlTextarea.value) {
|
const field = getUrlElement();
|
||||||
await adjustTextareaHeight();
|
if (field instanceof HTMLTextAreaElement) {
|
||||||
urlTextarea.value.textareaRef?.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
field.setSelectionRange(cursorPos + 1, cursorPos + 1);
|
||||||
urlTextarea.value.textareaRef?.focus();
|
field.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -714,11 +714,11 @@ const handlePaste = async (event: ClipboardEvent): Promise<void> => {
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
if (urlTextarea.value) {
|
const field = getUrlElement();
|
||||||
await adjustTextareaHeight();
|
if (field instanceof HTMLTextAreaElement) {
|
||||||
const newPos = start + pastedText.length;
|
const newPos = start + pastedText.length;
|
||||||
urlTextarea.value.textareaRef?.setSelectionRange(newPos, newPos);
|
field.setSelectionRange(newPos, newPos);
|
||||||
urlTextarea.value.textareaRef?.focus();
|
field.focus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -944,10 +944,6 @@ onMounted(async () => {
|
||||||
if (!separators.some((s) => s.value === separator.value)) {
|
if (!separators.some((s) => s.value === separator.value)) {
|
||||||
separator.value = separators[0]?.value ?? ',';
|
separator.value = separators[0]?.value ?? ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMultiLineInput.value && urlTextarea.value) {
|
|
||||||
await adjustTextareaHeight();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const runCliCommand = async (): Promise<void> => {
|
const runCliCommand = async (): Promise<void> => {
|
||||||
|
|
@ -1148,11 +1144,9 @@ const hasValidUrl = computed(() => form.value.url && form.value.url.trim().lengt
|
||||||
watch(isMultiLineInput, async (newValue) => {
|
watch(isMultiLineInput, async (newValue) => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
await adjustTextareaHeight();
|
|
||||||
urlTextarea.value?.textareaRef?.focus();
|
urlTextarea.value?.textareaRef?.focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const inputElement = document.getElementById('url') as HTMLInputElement;
|
getUrlElement()?.focus();
|
||||||
inputElement?.focus();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue