Skip to content

Commit 794ef01

Browse files
committed
revert changes and update doc instead
1 parent 5a0b1f0 commit 794ef01

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

src/lib/sidenav/drawer.spec.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,6 @@ describe('MdDrawer', () => {
102102
expect(testComponent.backdropClickedCount).toBe(1);
103103
}));
104104

105-
it('should emit the escapeKeydown event when ESCAPE key is pressed', () => {
106-
let fixture = TestBed.createComponent(BasicTestApp);
107-
let testComponent: BasicTestApp = fixture.debugElement.componentInstance;
108-
let drawer = fixture.debugElement.query(By.directive(MdDrawer));
109-
expect(testComponent.escapeKeydownCount).toBe(0);
110-
111-
dispatchKeyboardEvent(drawer.nativeElement, 'keydown', ESCAPE);
112-
fixture.detectChanges();
113-
114-
expect(testComponent.escapeKeydownCount).toBe(1);
115-
});
116-
117105
it('should close when pressing escape', fakeAsync(() => {
118106
let fixture = TestBed.createComponent(BasicTestApp);
119107

@@ -398,8 +386,7 @@ class DrawerContainerTwoDrawerTestApp {
398386
<md-drawer-container (backdropClick)="backdropClicked()">
399387
<md-drawer #drawer position="start"
400388
(open)="open()"
401-
(close)="close()"
402-
(escapeKeydown)="escapeKeydown()">
389+
(close)="close()">
403390
<button #drawerButton>Content.</button>
404391
</md-drawer>
405392
<button (click)="drawer.open()" class="open" #openButton></button>
@@ -427,10 +414,6 @@ class BasicTestApp {
427414
backdropClicked() {
428415
this.backdropClickedCount++;
429416
}
430-
431-
escapeKeydown() {
432-
this.escapeKeydownCount++;
433-
}
434417
}
435418

436419
@Component({

src/lib/sidenav/drawer.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
152152
/** Event emitted when the drawer's position changes. */
153153
@Output('positionChanged') onPositionChanged = new EventEmitter<void>();
154154

155-
/** Event emitted when ESCAPE is pressed. */
156-
@Output() escapeKeydown = new EventEmitter<void>();
157-
158155
/** @deprecated */
159156
@Output('align-changed') onAlignChanged = new EventEmitter<void>();
160157

@@ -262,12 +259,9 @@ export class MdDrawer implements AfterContentInit, OnDestroy {
262259
* @docs-private
263260
*/
264261
handleKeydown(event: KeyboardEvent) {
265-
if (event.keyCode === ESCAPE) {
266-
this.escapeKeydown.emit();
267-
if (!this.disableClose) {
268-
this.close();
269-
event.stopPropagation();
270-
}
262+
if (event.keyCode === ESCAPE && !this.disableClose) {
263+
this.close();
264+
event.stopPropagation();
271265
}
272266
}
273267

src/lib/sidenav/sidenav.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,19 @@ html, body, material-app, md-sidenav-container, .my-content {
7070
### FABs inside sidenav
7171
For a sidenav with a FAB (Floating Action Button) or other floating element, the recommended approach is to place the FAB
7272
outside of the scrollable region and absolutely position it.
73+
74+
### Sidenav vs. Drawer
75+
The difference between sidenav and drawer is that the sidenav takes up fullscreen whereas drawer is a smaller element
76+
that takes up a subsection of the screen. `md-sidenav` has to be placed inside `md-sidenav-container` and `md-drawer`
77+
has to be placed inside `md-drawer-container`. More functionalities will be added to sidenav in the future.
78+
79+
80+
### Disabling closing of sidenav and drawer
81+
By default, sidenav and drawer can be closed either by clicking on the backdrop or by pressing <kbd>ESCAPE</kbd>.
82+
`disableClose` attribute can be set on `md-drawer` or `md-sidenav` to disable closing by two methods. To enable one
83+
of the two methods to allow closing with `disableClose` attribute set, then custom event handlers can be used as below:
84+
```html
85+
<md-drawer-container (backdropClick)="customBackdropClickHandler()">
86+
<md-drawer disableClose (keydown)="customKeydownHandler($event)"></md-drawer>
87+
</md-drawer-container>
88+
```

0 commit comments

Comments
 (0)