Skip to content

Commit

Permalink
fix(menu): update to use overlay backdrop
Browse files Browse the repository at this point in the history
  • Loading branch information
kara committed Oct 19, 2016
1 parent e2b1c87 commit a8043cb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
10 changes: 0 additions & 10 deletions src/lib/menu/menu-directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {UP_ARROW, DOWN_ARROW, TAB} from '../core';
exportAs: 'mdMenu'
})
export class MdMenu {
_showClickCatcher: boolean = false;
private _focusedItemIndex: number = 0;

// config object to be passed into the menu's ngClass
Expand Down Expand Up @@ -61,15 +60,6 @@ export class MdMenu {

@Output() close = new EventEmitter;

/**
* This function toggles the display of the menu's click catcher element.
* This element covers the viewport when the menu is open to detect clicks outside the menu.
* TODO: internal
*/
_setClickCatcher(bool: boolean): void {
this._showClickCatcher = bool;
}

/**
* Focus the first item in the menu. This method is used by the menu trigger
* to focus the first item when the menu is opened by the ENTER key.
Expand Down
4 changes: 3 additions & 1 deletion src/lib/menu/menu-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
if (!this._menuOpen) {
this._createOverlay();
this._overlayRef.attach(this._portal);
this._overlayRef.backdropClick().subscribe(() => this.closeMenu());
this._initMenu();
}
}
Expand Down Expand Up @@ -119,7 +120,6 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
// set state rather than toggle to support triggers sharing a menu
private _setIsMenuOpen(isOpen: boolean): void {
this._menuOpen = isOpen;
this.menu._setClickCatcher(isOpen);
this._menuOpen ? this.onMenuOpen.emit(null) : this.onMenuClose.emit(null);
}

Expand Down Expand Up @@ -151,6 +151,8 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
private _getOverlayConfig(): OverlayState {
const overlayState = new OverlayState();
overlayState.positionStrategy = this._getPosition();
overlayState.hasBackdrop = true;
overlayState.backdropClass = 'md-overlay-transparent-backdrop';
return overlayState;
}

Expand Down
3 changes: 1 addition & 2 deletions src/lib/menu/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
<div class="md-menu" [ngClass]="_classList" (click)="_emitCloseEvent()" (keydown)="_handleKeydown($event)">
<ng-content></ng-content>
</div>
</template>
<div class="md-menu-click-catcher" *ngIf="_showClickCatcher" (click)="_emitCloseEvent()"></div>
</template>
6 changes: 1 addition & 5 deletions src/lib/menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,4 @@ $md-menu-vertical-padding: 8px !default;

button[md-menu-item] {
width: 100%;
}

.md-menu-click-catcher {
@include md-fullscreen();
}
}

0 comments on commit a8043cb

Please sign in to comment.