diff --git a/ui/app/components/NewDownload.vue b/ui/app/components/NewDownload.vue index 8af6845c..b8136148 100644 --- a/ui/app/components/NewDownload.vue +++ b/ui/app/components/NewDownload.vue @@ -37,7 +37,6 @@ base: 'min-h-[7.25rem] bg-elevated/60 ring-default focus-visible:ring-primary', }" @keydown="handleKeyDown" - @input="() => void adjustTextareaHeight()" /> { return false; }; -const adjustTextareaHeight = async (): Promise => { - await nextTick(); - urlTextarea.value?.textareaRef?.dispatchEvent(new Event('input', { bubbles: true })); +const getUrlElement = (): HTMLInputElement | HTMLTextAreaElement | null => { + return ( + urlTextarea.value?.textareaRef || (document.getElementById('url') as HTMLInputElement | null) + ); }; const handleKeyDown = async (event: KeyboardEvent): Promise => { @@ -690,10 +690,10 @@ const handleKeyDown = async (event: KeyboardEvent): Promise => { await nextTick(); - if (urlTextarea.value) { - await adjustTextareaHeight(); - urlTextarea.value.textareaRef?.setSelectionRange(cursorPos + 1, cursorPos + 1); - urlTextarea.value.textareaRef?.focus(); + const field = getUrlElement(); + if (field instanceof HTMLTextAreaElement) { + field.setSelectionRange(cursorPos + 1, cursorPos + 1); + field.focus(); } } }; @@ -714,11 +714,11 @@ const handlePaste = async (event: ClipboardEvent): Promise => { await nextTick(); - if (urlTextarea.value) { - await adjustTextareaHeight(); + const field = getUrlElement(); + if (field instanceof HTMLTextAreaElement) { const newPos = start + pastedText.length; - urlTextarea.value.textareaRef?.setSelectionRange(newPos, newPos); - urlTextarea.value.textareaRef?.focus(); + field.setSelectionRange(newPos, newPos); + field.focus(); } }; @@ -944,10 +944,6 @@ onMounted(async () => { if (!separators.some((s) => s.value === separator.value)) { separator.value = separators[0]?.value ?? ','; } - - if (isMultiLineInput.value && urlTextarea.value) { - await adjustTextareaHeight(); - } }); const runCliCommand = async (): Promise => { @@ -1148,11 +1144,9 @@ const hasValidUrl = computed(() => form.value.url && form.value.url.trim().lengt watch(isMultiLineInput, async (newValue) => { await nextTick(); if (newValue) { - await adjustTextareaHeight(); urlTextarea.value?.textareaRef?.focus(); return; } - const inputElement = document.getElementById('url') as HTMLInputElement; - inputElement?.focus(); + getUrlElement()?.focus(); });