1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

Add back in auto focus behaviour to modals but disable it for screen creation

This commit is contained in:
Andrew Kingston 2023-08-25 16:45:41 +01:00
parent abbc4f7d2a
commit 6c38eb5a4c
2 changed files with 13 additions and 1 deletions

View file

@ -9,6 +9,7 @@
export let fixed = false
export let inline = false
export let disableCancel = false
export let autoFocus = true
const dispatch = createEventDispatcher()
let visible = fixed || inline
@ -53,6 +54,9 @@
}
async function focusModal(node) {
if (!autoFocus) {
return
}
await tick()
// Try to focus first input
@ -60,6 +64,14 @@
if (inputs?.length) {
inputs[0].focus()
}
// Otherwise try to focus confirmation button
else if (modal) {
const confirm = modal.querySelector(".confirm-wrap .spectrum-Button")
if (confirm) {
confirm.focus()
}
}
}
setContext(Context.Modal, { show, hide, toggle, cancel })

View file

@ -175,7 +175,7 @@
}
</script>
<Modal bind:this={datasourceModal}>
<Modal bind:this={datasourceModal} autoFocus={false}>
<DatasourceModal
onConfirm={confirmScreenDatasources}
initialScreens={!selectedTemplates ? [] : [...selectedTemplates]}