This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 102
102
* <!-- menu-content -->
103
103
* </md-menu>
104
104
* </hljs>
105
+
106
+ * ### Preventing close
107
+ *
108
+ * Sometimes you would like to be able to click on a menu item without having the menu
109
+ * close. To do this, ngMaterial exposes the `md-prevent-menu-close` attribute which
110
+ * can be added to a button inside a menu to stop the menu from automatically closing.
111
+ * You can then close the menu programatically by injecting `$mdMenu` and calling
112
+ * `$mdMenu.hide()`.
113
+ *
114
+ * <hljs lang="html">
115
+ * <md-menu-item>
116
+ * <md-button ng-click="doSomething()" aria-label="Do something" md-prevent-menu-close="md-prevent-menu-close">
117
+ * <md-icon md-menu-align-target md-svg-icon="call:phone"></md-icon>
118
+ * Do Something
119
+ * </md-button>
120
+ * </md-menu-item>
121
+ * </hljs>
105
122
*
106
123
* @usage
107
124
* <hljs lang="html">
Original file line number Diff line number Diff line change @@ -291,8 +291,8 @@ function MenuProvider($$interimElementProvider) {
291
291
// there is an ng-click and that the ng-click is not disabled
292
292
do {
293
293
if ( target == opts . menuContentEl [ 0 ] ) return ;
294
- if ( hasAnyAttribute ( target , [ 'ng-click' , 'ng-href' , 'ui-sref' ] ) ||
295
- target . nodeName == 'BUTTON' || target . nodeName == 'MD-BUTTON' ) {
294
+ if ( ( hasAnyAttribute ( target , [ 'ng-click' , 'ng-href' , 'ui-sref' ] ) ||
295
+ target . nodeName == 'BUTTON' || target . nodeName == 'MD-BUTTON' ) && ! hasAnyAttribute ( target , [ 'md-prevent-menu-close' ] ) ) {
296
296
var closestMenu = $mdUtil . getClosest ( target , 'MD-MENU' ) ;
297
297
if ( ! target . hasAttribute ( 'disabled' ) && ( ! closestMenu || closestMenu == opts . parent [ 0 ] ) ) {
298
298
close ( ) ;
You can’t perform that action at this time.
0 commit comments