diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue index f05d1e91c..98645873b 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue @@ -18,22 +18,20 @@ interface DownloadButtonConfig { } interface DownloadButtonState { - content: null|string + is_ready: boolean } const props = defineProps(); -const state: DownloadButtonState = reactive({content: null}); +const state: DownloadButtonState = reactive({is_ready: false}); async function download_and_open(event: Event): Promise { const button = event.target as HTMLAnchorElement; - if (null === state.content) { + if (!state.is_ready) { event.preventDefault(); - const urlInfo = build_download_info_link(props.storedObject.filename); const raw = await download_and_decrypt_doc(urlInfo, props.storedObject.keyInfos, new Uint8Array(props.storedObject.iv)); - state.content = window.URL.createObjectURL(raw); button.href = window.URL.createObjectURL(raw); button.type = props.storedObject.type; @@ -44,8 +42,13 @@ async function download_and_open(event: Event): Promise { if (null !== ext) { button.download = button.download + '.' + ext; } - } - button.click(); + state.is_ready = true; + + // for fixing https://gitlab.com/Chill-Projet/chill-bundles/-/issues/98 + window.setTimeout(() => { + button.click() + }, 750); + } }