Add back in auto focus behaviour to modals but disable it for screen creation
This commit is contained in:
parent
abbc4f7d2a
commit
6c38eb5a4c
|
@ -9,6 +9,7 @@
|
||||||
export let fixed = false
|
export let fixed = false
|
||||||
export let inline = false
|
export let inline = false
|
||||||
export let disableCancel = false
|
export let disableCancel = false
|
||||||
|
export let autoFocus = true
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let visible = fixed || inline
|
let visible = fixed || inline
|
||||||
|
@ -53,6 +54,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function focusModal(node) {
|
async function focusModal(node) {
|
||||||
|
if (!autoFocus) {
|
||||||
|
return
|
||||||
|
}
|
||||||
await tick()
|
await tick()
|
||||||
|
|
||||||
// Try to focus first input
|
// Try to focus first input
|
||||||
|
@ -60,6 +64,14 @@
|
||||||
if (inputs?.length) {
|
if (inputs?.length) {
|
||||||
inputs[0].focus()
|
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 })
|
setContext(Context.Modal, { show, hide, toggle, cancel })
|
||||||
|
|
|
@ -175,7 +175,7 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:this={datasourceModal}>
|
<Modal bind:this={datasourceModal} autoFocus={false}>
|
||||||
<DatasourceModal
|
<DatasourceModal
|
||||||
onConfirm={confirmScreenDatasources}
|
onConfirm={confirmScreenDatasources}
|
||||||
initialScreens={!selectedTemplates ? [] : [...selectedTemplates]}
|
initialScreens={!selectedTemplates ? [] : [...selectedTemplates]}
|
||||||
|
|
Loading…
Reference in New Issue