Skip to content

fix(sidenav): avoid CSS class name conflict #16798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/material/sidenav/drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $mat-drawer-over-drawer-z-index: 4;
&[fullscreen] {
@include mat-fill();

&.mat-drawer-opened {
&.mat-drawer-container-has-open {
overflow: hidden;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/material/sidenav/drawer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ describe('MatDrawer', () => {

expect(testComponent.openCount).toBe(0);
expect(testComponent.openStartCount).toBe(0);
expect(container.classList).not.toContain('mat-drawer-opened');
expect(container.classList).not.toContain('mat-drawer-container-has-open');

tick();
expect(testComponent.openStartCount).toBe(1);
fixture.detectChanges();

expect(testComponent.openCount).toBe(1);
expect(testComponent.openStartCount).toBe(1);
expect(container.classList).toContain('mat-drawer-opened');
expect(container.classList).toContain('mat-drawer-container-has-open');
}));

it('should be able to close', fakeAsync(() => {
Expand All @@ -80,15 +80,15 @@ describe('MatDrawer', () => {

expect(testComponent.closeCount).toBe(0);
expect(testComponent.closeStartCount).toBe(0);
expect(container.classList).toContain('mat-drawer-opened');
expect(container.classList).toContain('mat-drawer-container-has-open');

flush();
expect(testComponent.closeStartCount).toBe(1);
fixture.detectChanges();

expect(testComponent.closeCount).toBe(1);
expect(testComponent.closeStartCount).toBe(1);
expect(container.classList).not.toContain('mat-drawer-opened');
expect(container.classList).not.toContain('mat-drawer-container-has-open');
}));

it('should resolve the open method promise with the new state of the drawer', fakeAsync(() => {
Expand Down
7 changes: 5 additions & 2 deletions src/material/sidenav/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,10 +715,13 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy

/** Toggles the 'mat-drawer-opened' class on the main 'mat-drawer-container' element. */
private _setContainerClass(isAdd: boolean): void {
const classList = this._element.nativeElement.classList;
const className = 'mat-drawer-container-has-open';

if (isAdd) {
this._element.nativeElement.classList.add('mat-drawer-opened');
classList.add(className);
} else {
this._element.nativeElement.classList.remove('mat-drawer-opened');
classList.remove(className);
}
}

Expand Down