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;
|
||||
case "template":
|
||||
flowBody.innerHTML = data.body;
|
||||
checkAutofocus();
|
||||
updateMessages();
|
||||
loadFormCode();
|
||||
setFormSubmitHandlers();
|
||||
|
@ -138,6 +139,12 @@ const loadFormCode = () => {
|
|||
document.head.appendChild(newScript);
|
||||
});
|
||||
};
|
||||
const checkAutofocus = () => {
|
||||
const autofocusElement = document.querySelector("#flow-body [autofocus]");
|
||||
if (autofocusElement !== null) {
|
||||
autofocusElement.focus();
|
||||
}
|
||||
};
|
||||
const updateFormAction = (form) => {
|
||||
for (let index = 0; index < form.elements.length; index++) {
|
||||
const element = form.elements[index];
|
||||
|
|
Reference in a new issue