summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordsnopek2017-10-15 15:45:29 (GMT)
committerolstjos2017-10-15 15:45:29 (GMT)
commit6faeabac327fb37e2db4c13eafa6809ffbf071b6 (patch)
treeb9eb3ab0075a785d380c221f5514e56a9c353ddd
parent9615f595fbc85857cf6e498f271f768662d20acd (diff)
Issue #2914241 by dsnopek: Focus not confined to modal Media Browser - keyboard trap
-rw-r--r--js/media.browser.js21
-rw-r--r--js/media.popups.js2
2 files changed, 22 insertions, 1 deletions
diff --git a/js/media.browser.js b/js/media.browser.js
index bfd2fe0..0fc5015 100644
--- a/js/media.browser.js
+++ b/js/media.browser.js
@@ -40,6 +40,27 @@ Drupal.behaviors.MediaBrowser = {
});
$('.media-browser-tab').each( Drupal.media.browser.validateButtons );
+
+ // Keep keyboard focus from going to the browser chrome.
+ $('body', context).once(function () {
+ $(window).on('keydown', function (event) {
+ if (event.keyCode === 9) {
+ var tabbables = $(':tabbable'),
+ first = tabbables.filter(':first'),
+ last = tabbables.filter(':last'),
+ new_event;
+ if ((event.target === last[0] && !event.shiftKey) || (event.target === first[0] && event.shiftKey)) {
+ // If we're at the end of the tab list, then send a keyboard event
+ // to the parent iframe.
+ if (parent_iframe = Drupal.media.browser.getParentIframe(window)) {
+ $('.ui-dialog-titlebar-close', $(parent_iframe).closest('.ui-dialog')).focus();
+ event.preventDefault();
+ return false;
+ }
+ }
+ }
+ });
+ });
}
// Wait for additional params to be passed in.
};
diff --git a/js/media.popups.js b/js/media.popups.js
index d7d7d0d..2dadd99 100644
--- a/js/media.popups.js
+++ b/js/media.popups.js
@@ -374,7 +374,7 @@ Drupal.media.popups.getPopupIframe = function (src, id, options) {
var defaults = {width: '100%', scrolling: 'auto'};
var options = $.extend({}, defaults, options);
- return $('<iframe class="media-modal-frame"/>')
+ return $('<iframe class="media-modal-frame" tabindex="0"/>')
.attr('src', src)
.attr('width', options.width)
.attr('id', id)