Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(dialog): switch dialog to use disableScroll, fix focus trap
Browse files Browse the repository at this point in the history
closes #2443
  • Loading branch information
rschmukler committed Jun 28, 2015
1 parent 4f7af22 commit 862444a
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,6 @@ function MdDialogProvider($$interimElementProvider) {
}
};

function trapFocus(ev) {
var dialog = document.querySelector('md-dialog');

if (dialog && !dialog.contains(ev.target)) {
ev.stopImmediatePropagation();
dialog.focus();
}
}

// On show method for dialogs
function onShow(scope, element, options) {
Expand Down Expand Up @@ -484,11 +476,9 @@ function MdDialogProvider($$interimElementProvider) {

configureAria(element.find('md-dialog'), role, options);

document.addEventListener('focus', trapFocus, true);

if (options.disableParentScroll) {
options.lastOverflow = options.parent.css('overflow');
options.parent.css('overflow', 'hidden');
options.restoreScroll = $mdUtil.disableScrollAround(element);
}

return dialogPopIn(
Expand Down Expand Up @@ -546,8 +536,7 @@ function MdDialogProvider($$interimElementProvider) {
$animate.leave(options.backdrop);
}
if (options.disableParentScroll) {
options.parent.css('overflow', options.lastOverflow);
delete options.lastOverflow;
options.restoreScroll();
}
if (options.escapeToClose) {
$rootElement.off('keyup', options.rootElementKeyupCallback);
Expand All @@ -558,7 +547,6 @@ function MdDialogProvider($$interimElementProvider) {

applyAriaToSiblings(element, false);

document.removeEventListener('focus', trapFocus, true);

return dialogPopOut(
element,
Expand Down

0 comments on commit 862444a

Please sign in to comment.