feat(attachments): open file picker directly from sidebar button

Clicking the sidebar "Attachments" button (or pressing `f`) now opens
the browser file picker directly, eliminating the redundant two-step
flow of first revealing the section and then clicking upload.
This commit is contained in:
kolaente 2026-02-19 12:48:29 +01:00
parent 0026c74fb5
commit 50d7458519
2 changed files with 19 additions and 2 deletions

View File

@ -383,6 +383,10 @@ async function setCoverImage(attachment: IAttachment | null) {
emit('taskChanged', updatedTask)
success({message: t('task.attachment.successfullyChangedCoverImage')})
}
defineExpose({
openFilePicker: () => filesRef.value?.click(),
})
</script>
<style lang="scss" scoped>

View File

@ -351,7 +351,7 @@
class="content attachments"
>
<Attachments
:ref="e => setFieldRef('attachments', e)"
:ref="e => { setFieldRef('attachments', e); attachmentsRef = e as any }"
:edit-enabled="canWrite"
:task="task"
@taskChanged="({coverImageAttachmentId}) => task.coverImageAttachmentId = coverImageAttachmentId"
@ -499,7 +499,7 @@
v-shortcut="'f'"
variant="secondary"
icon="paperclip"
@click="setFieldActive('attachments')"
@click="openAttachments()"
>
{{ $t('task.detail.actions.attachments') }}
</XButton>
@ -793,6 +793,8 @@ async function scrollToHeading() {
scrollIntoView(unrefElement(heading))
}
const attachmentsRef = ref<InstanceType<typeof Attachments> | null>(null)
const taskViewContainer = ref<HTMLElement | null>(null)
const scrollContainer = ref<HTMLElement | null>(null)
const contentBottomMarker = ref<HTMLElement | null>(null)
@ -997,6 +999,17 @@ function setFieldActive(fieldName: keyof typeof activeFields) {
})
}
function openAttachments() {
activeFields.attachments = true
nextTick(() => {
const el = activeFieldElements.attachments
if (el) {
scrollIntoView(el)
}
attachmentsRef.value?.openFilePicker()
})
}
async function saveTask(
currentTask: ITask | null = null,
undoCallback?: () => void,