flows/shell: check for elements with autofocus attribute and call .focus();
closes #76
This commit is contained in:
parent
3713d111a4
commit
afc8baff5f
|
@ -120,6 +120,7 @@ const updateCard = (data) => {
|
||||||
break;
|
break;
|
||||||
case "template":
|
case "template":
|
||||||
flowBody.innerHTML = data.body;
|
flowBody.innerHTML = data.body;
|
||||||
|
checkAutofocus();
|
||||||
updateMessages();
|
updateMessages();
|
||||||
loadFormCode();
|
loadFormCode();
|
||||||
setFormSubmitHandlers();
|
setFormSubmitHandlers();
|
||||||
|
@ -138,6 +139,12 @@ const loadFormCode = () => {
|
||||||
document.head.appendChild(newScript);
|
document.head.appendChild(newScript);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const checkAutofocus = () => {
|
||||||
|
const autofocusElement = document.querySelector("#flow-body [autofocus]");
|
||||||
|
if (autofocusElement !== null) {
|
||||||
|
autofocusElement.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
const updateFormAction = (form) => {
|
const updateFormAction = (form) => {
|
||||||
for (let index = 0; index < form.elements.length; index++) {
|
for (let index = 0; index < form.elements.length; index++) {
|
||||||
const element = form.elements[index];
|
const element = form.elements[index];
|
||||||
|
|
Reference in New Issue