Loading core/misc/dialog/dialog.ajax.js +36 −2 Original line number Diff line number Diff line Loading @@ -44,8 +44,42 @@ if (!dialog.contains(document.activeElement)) { // Move focus to the first focusable element in the next event loop // to allow dialog buttons to be changed first. $(dialog).dialog('instance')._focusedElement = null; $(dialog).dialog('instance')._focusTabbable(); // Replicate the autofocus behavior of jQuery UI Dialog. const autoFocusElement = dialog?.querySelector('[autofocus]'); if (autoFocusElement) { autoFocusElement.focus(); return; } const focusableElements = focusable(dialog); if (focusableElements.length > 0) { focusableElements[0].focus(); return; } const dialogWrapper = dialog.closest('.ui-dialog'); const buttonPane = dialogWrapper?.querySelector( '.ui-dialog-buttonpane', ); const focusableButtons = focusable(buttonPane); if (focusableButtons.length > 0) { focusableButtons[0].focus(); return; } const closeButton = dialogWrapper?.querySelector( '.ui-dialog-titlebar-close', ); if (closeButton) { closeButton.focus(); return; } dialog.focus(); } }, 0); } Loading Loading
core/misc/dialog/dialog.ajax.js +36 −2 Original line number Diff line number Diff line Loading @@ -44,8 +44,42 @@ if (!dialog.contains(document.activeElement)) { // Move focus to the first focusable element in the next event loop // to allow dialog buttons to be changed first. $(dialog).dialog('instance')._focusedElement = null; $(dialog).dialog('instance')._focusTabbable(); // Replicate the autofocus behavior of jQuery UI Dialog. const autoFocusElement = dialog?.querySelector('[autofocus]'); if (autoFocusElement) { autoFocusElement.focus(); return; } const focusableElements = focusable(dialog); if (focusableElements.length > 0) { focusableElements[0].focus(); return; } const dialogWrapper = dialog.closest('.ui-dialog'); const buttonPane = dialogWrapper?.querySelector( '.ui-dialog-buttonpane', ); const focusableButtons = focusable(buttonPane); if (focusableButtons.length > 0) { focusableButtons[0].focus(); return; } const closeButton = dialogWrapper?.querySelector( '.ui-dialog-titlebar-close', ); if (closeButton) { closeButton.focus(); return; } dialog.focus(); } }, 0); } Loading