Commit 6faeabac authored by dsnopek's avatar dsnopek Committed by joseph.olstad

Issue #2914241 by dsnopek: Focus not confined to modal Media Browser - keyboard trap

parent 9615f595
......@@ -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.
};
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment