fix: confirmation dialog for archive was considered by browser like automatic download and not as issued by user

Massimo Melina committed Jan 19, 2022 at 23:12 UTC 8abd366872542b8fc62a9080b51a5ef5111c68af
2 files changed +7 -9
frontend/src/dialog.ts
+6 -7
@@ -141,7 +141,8 @@ export async function alertDialog(msg: ReactElement | string | Error, type:Alert
141 }
142 }
143
144 -export async function confirmDialog(msg: string) : Promise<boolean> {
144 +interface ConfirmOptions { href?: string }
145 +export async function confirmDialog(msg: string, { href }: ConfirmOptions={}) : Promise<boolean> {
146 return new Promise(resolve => newDialog({
147 className: 'dialog-confirm',
148 icon: '?',
@@ -152,12 +153,10 @@ export async function confirmDialog(msg: string) : Promise<boolean> {
153 function Content() {
154 return h('div', {},
155 h('p', {}, msg),
155 - h('button', {
156 - autoFocus: true,
157 - onClick(){
158 - closeDialog(true)
159 - }
160 - }, 'Confirm')
156 + h('a', {
157 + href,
158 + onClick: () => closeDialog(true),
159 + }, h('button', {}, 'Confirm'))
160 )
161 }
162 }
frontend/src/menu.ts
+1 -2
@@ -102,8 +102,7 @@ export function MenuLink({ href, confirm, ...rest }: MenuButtonProps & { href: s
102 async onClick(ev) {
103 if (!confirm) return
104 ev.preventDefault()
105 - if (!await confirmDialog(confirm)) return
106 - window.location.href = href
105 + await confirmDialog(confirm, { href })
106 }
107 }, h(MenuButton, rest))
108 }