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

Added mdPreventRefocus in sideNav #8179

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/sidenav/sidenav.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $animate,
return {
restrict: 'E',
scope: {
isOpen: '=?mdIsOpen'
isOpen: '=?mdIsOpen',
mdPreventRefocus: '=?'
},
controller: '$mdSidenavController',
compile: function(element) {
Expand Down Expand Up @@ -283,7 +284,6 @@ function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $animate,
scope.$watch(isLocked, updateIsLocked);
scope.$watch('isOpen', updateIsOpen);


// Publish special accessor for the Controller instance
sidenavCtrl.$toggleOpen = toggleOpen;

Expand Down Expand Up @@ -374,8 +374,9 @@ function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $animate,
// When the current `updateIsOpen()` animation finishes
promise.then(function(result) {

if ( !scope.isOpen ) {
if ( !scope.isOpen && !scope.mdPreventRefocus ) {
// reset focus to originating element (if available) upon close
// this can now be disabled by using mdPreventRefocus
triggeringElement && triggeringElement.focus();
triggeringElement = null;
}
Expand Down