Skip to content

chore(tabs): use custom portal template directive for hosting tab body content - #7266

Merged
josephperrott merged 1 commit into
angular:masterfrom
josephperrott:tabs
Nov 10, 2017
Merged

josephperrott merged 1 commit into
angular:masterfrom
josephperrott:tabs

Conversation

@josephperrott

@josephperrott josephperrott commented Sep 22, 2017 •

Copy link
Copy Markdown
Member

Related to #6832
By moving the entrance logic into the MdTabBodyPortal setting up the content after change detection is avoided.

Fixes #7032 #7061

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 22, 2017
@josephperrott
josephperrott force-pushed the tabs branch 2 times, most recently from 2ce1567 to f552539 Compare September 22, 2017 20:35
Comment thread src/lib/tabs/tab-body.ts Outdated
@Output() onCentering: EventEmitter<number> = new EventEmitter<number>();

/** Event emitted when the tab completes its animation away from the center. */
@Output() afterLeavingCenter: EventEmitter<number> = new EventEmitter<number>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we prefix this w/ a underscore since its private ... so _afterLeavingCenter?

Whats the number type used for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done, and the number was the result of a copy paste from the emitter above. Since I wasn't using the result at all I didn't notice.

@josephperrott josephperrott added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful pr: needs review labels Sep 22, 2017
@josephperrott

Copy link
Copy Markdown
Member Author

@andrewseguin If you have a moment to take a look. :D

Comment thread src/lib/tabs/tab-body.spec.ts Outdated
it('should attach when first made visible', fakeAsync(() => {
fixture.componentInstance.position = 1;
fixture.detectChanges();
tick(1000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leave comment explaining where 1000 came from and why tick was needed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/lib/tabs/tab-body.ts Outdated
})
export class MdTabBodyPortal extends _MdTabBodyPortalBaseClass implements OnInit {
/** Whether the tab body should be visible. */
visible = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like the subs should be private (preceeded with an underscore)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment thread src/lib/tabs/tab-body.ts

constructor(
_componentFactoryResolver: ComponentFactoryResolver,
_viewContainerRef: ViewContainerRef,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add underscore to host to show its private

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment thread src/lib/tabs/tab-body.ts Outdated

/** Set up subscriptions for changing visibility and set initial visibility. */
ngOnInit(): void {
this.centeringSub = this.host.onCentering.subscribe(() => this.setVisibility(true));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this.leavingCenterSub = 
    this.host._afterLeavingCenter.subscribe(() => this.setVisibility(false));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done


tabGroup.selectedIndex = 2;
fixture.detectChanges();
fixture.whenStable().then(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add comment why whenStable is needed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Comment thread src/lib/tabs/tabs.spec.ts Outdated
@@ -0,0 +1,44 @@
import {Component} from '@angular/core';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure why the extra test is needed, isn't this covered by tab-group.spec.ts?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was not caught by the current tests in tab-group.spec.ts, would you prefer I move it into tab-group.spec.ts?

Comment thread src/lib/tabs/tab-body.ts Outdated

/** Whether the provided position state is considered center, regardless of origin. */
private _isCenterPosition(position: MdTabBodyPositionState|string): boolean {
_isCenterPosition(position: MdTabBodyPositionState|string): boolean {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will need to remove the underscore if it's not private.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ack.

@andrewseguin andrewseguin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM - nice work, takes a lot to get a good hold of all the change detection pieces happening in the tabs component

@andrewseguin

Copy link
Copy Markdown
Contributor

Add merge_ready after you move the test to tab-group.spec.ts

Comment thread src/lib/tabs/tab-body.ts

constructor(
_componentFactoryResolver: ComponentFactoryResolver,
_viewContainerRef: ViewContainerRef,

@mmalerba mmalerba Sep 25, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@josephperrott it looks like we need to use a forwardRef here since this directive is used in the template for MdTabBody. Here's an example for a similar situation in the sidenav: https://github.com/angular/material2/blob/master/src/lib/sidenav/sidenav.ts#L36

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label Sep 25, 2017
@josephperrott
josephperrott force-pushed the tabs branch 2 times, most recently from 4dfdf85 to d587250 Compare September 25, 2017 15:32
@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Sep 25, 2017
@mmalerba

Copy link
Copy Markdown
Contributor

@josephperrott This seems to break tab animations in some cases. Go to tabs demo page under "Tab Group Demo - Dynamic Tabs" and click "Tab 4" to see the broken behavior

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label Sep 26, 2017
@josephperrott

Copy link
Copy Markdown
Member Author

@mmalerba Issue resolved.

@josephperrott josephperrott added the action: merge The PR is ready for merge by the caretaker label Sep 28, 2017
@amcdnl

amcdnl commented Oct 3, 2017

Copy link
Copy Markdown
Contributor

@josephperrott - Can you rebase?

@kara kara added the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Oct 3, 2017
@josephperrott
josephperrott force-pushed the tabs branch 2 times, most recently from 2a8a5e8 to b894fe8 Compare October 4, 2017 18:06
@jelbourn jelbourn added P2 The issue is important to a large percentage of users, with a workaround and removed P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful labels Oct 24, 2017
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Fast tab switch forces scroll up

7 participants