diff --git a/dialog.js b/dialog.js index 8dccf65..3b6a730 100644 --- a/dialog.js +++ b/dialog.js @@ -32,22 +32,6 @@ angular.module('ayDialog', []) var kZIndexMax = Math.pow(2, 31) - 1; - // Courtesy of AngularUI Bootstrap's $modal service - var FOCUS_SELECTOR = [ - 'a[href]', - 'area[href]', - 'input:not([disabled])', - 'button:not([disabled])', - 'select:not([disabled])', - 'textarea:not([disabled])', - 'keygen:not([disabled])', - 'iframe', - 'object', - 'embed', - '[tabindex]:not([disabled]):not([tabindex=""])', - '[contenteditable=true]' - ].join(','); - var DIALOG_STYLES = [ '[hidden] {', @@ -75,6 +59,10 @@ angular.module('ayDialog', []) ' -webkit-overflow-scrolling: touch;', '}', '', + 'dialog:focus {', + ' outline: 0 none;', + '}', + '', 'dialog[open] {', ' visibility: visible;', '}', @@ -124,21 +112,6 @@ angular.module('ayDialog', []) return; } - var control = el.querySelector(FOCUS_SELECTOR); - - if (control) { - if (immediate) { - control.focus(); - return; - } - - $window.setTimeout(function() { - control.focus(); - }, 1); - el.focus(); - return; - } - el.focus(); } @@ -312,6 +285,11 @@ angular.module('ayDialog', []) el.setAttribute('role', 'dialog'); } + // Ensure the dialog is focusable + if (!el.hasAttribute('tabindex')) { + el.tabIndex = -1; + } + if (('HTMLDialogElement' in $window) && (el instanceof $window.HTMLDialogElement))