Skip to content
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

feat(aio): close sidenav in narrow (mobile) mode when select a new doc #16617

Merged
merged 1 commit into from May 8, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions aio/src/app/app.component.spec.ts
Expand Up @@ -118,13 +118,13 @@ describe('AppComponent', () => {
expect(sidenav.className).toMatch(/sidenav-clos/);
});

it('should stay closed when nav to another guide page', () => {
it('should stay closed when nav from one guide page to another', () => {
locationService.go('guide/bags');
fixture.detectChanges();
expect(sidenav.className).toMatch(/sidenav-clos/);
});

it('should stay closed when nav to api page', () => {
it('should stay closed when nav from a guide page to api page', () => {
locationService.go('api');
fixture.detectChanges();
expect(sidenav.className).toMatch(/sidenav-clos/);
Expand Down Expand Up @@ -184,16 +184,16 @@ describe('AppComponent', () => {
expect(sidenav.className).toMatch(/sidenav-clos/);
});

it('should stay open when nav to another guide page', () => {
it('should close when nav to another guide page', () => {
locationService.go('guide/bags');
fixture.detectChanges();
expect(sidenav.className).toMatch(/sidenav-open/);
expect(sidenav.className).toMatch(/sidenav-clos/);
});

it('should stay open when nav to api page', () => {
it('should close when nav to api page', () => {
locationService.go('api');
fixture.detectChanges();
expect(sidenav.className).toMatch(/sidenav-open/);
expect(sidenav.className).toMatch(/sidenav-clos/);
});

it('should close again when nav to market page', () => {
Expand Down
17 changes: 11 additions & 6 deletions aio/src/app/app.component.ts
Expand Up @@ -116,13 +116,18 @@ export class AppComponent implements OnInit {

this.navigationService.currentNode.subscribe(currentNode => {
this.currentNode = currentNode;
this.updateHostClasses();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to this PR, but it fixes another issue with styling applied prematurely (before the document is fetched). Maybe worth putting into a separate commit and test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gkalpak do you mean this issue? #16635

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agreed to let this request go and merge.


// Toggle the sidenav if side-by-side and the kind of view changed
if (this.previousNavView === currentNode.view) { return; }
this.previousNavView = currentNode.view;
this.isSideNavDoc = currentNode.view === sideNavView;
this.sideNavToggle(this.isSideNavDoc && this.isSideBySide);
// Preserve current sidenav open state by default
let openSideNav = this.sidenav.opened;

if (this.previousNavView !== currentNode.view) {
this.previousNavView = currentNode.view;
// View type changed. Is it now a sidenav view (e.g, guide or tutorial)?
// Open if changed to a sidenav doc; close if changed to a marketing doc.
openSideNav = this.isSideNavDoc = currentNode.view === sideNavView;
}
// May be open or closed when wide; always closed when narrow
this.sideNavToggle(this.isSideBySide ? openSideNav : false);
});

this.navigationService.navigationViews.subscribe(views => {
Expand Down