diff --git a/js/src/dialog.js b/js/src/dialog.js index 67d0f0d..b93b2b0 100644 --- a/js/src/dialog.js +++ b/js/src/dialog.js @@ -64,6 +64,17 @@ export default class uDialog { if (!this.visible) { document.body.append(this.element); this.visible = true; + this.autofocus(); + } + } + + /** + * Set focus to element with autofocus attribute + */ + autofocus() { + const focusEl = this.element.querySelector('[autofocus]'); + if (focusEl) { + focusEl.focus(); } } diff --git a/js/src/positiondialogmodel.js b/js/src/positiondialogmodel.js index cfb985c..72d26d0 100644 --- a/js/src/positiondialogmodel.js +++ b/js/src/positiondialogmodel.js @@ -64,7 +64,7 @@ export default class PositionDialogModel extends ViewModel {