Repository navigation
chore(tabs): use custom portal template directive for hosting tab body content - #7266
Conversation
2ce1567 to
f552539
Compare
| @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>(); |
There was a problem hiding this comment.
Can we prefix this w/ a underscore since its private ... so _afterLeavingCenter?
Whats the number type used for?
There was a problem hiding this comment.
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.
|
@andrewseguin If you have a moment to take a look. :D |
| it('should attach when first made visible', fakeAsync(() => { | ||
| fixture.componentInstance.position = 1; | ||
| fixture.detectChanges(); | ||
| tick(1000); |
There was a problem hiding this comment.
Leave comment explaining where 1000 came from and why tick was needed
| }) | ||
| export class MdTabBodyPortal extends _MdTabBodyPortalBaseClass implements OnInit { | ||
| /** Whether the tab body should be visible. */ | ||
| visible = false; |
There was a problem hiding this comment.
Looks like the subs should be private (preceeded with an underscore)
|
|
||
| constructor( | ||
| _componentFactoryResolver: ComponentFactoryResolver, | ||
| _viewContainerRef: ViewContainerRef, |
There was a problem hiding this comment.
Add underscore to host to show its private
|
|
||
| /** Set up subscriptions for changing visibility and set initial visibility. */ | ||
| ngOnInit(): void { | ||
| this.centeringSub = this.host.onCentering.subscribe(() => this.setVisibility(true)); |
There was a problem hiding this comment.
this.leavingCenterSub =
this.host._afterLeavingCenter.subscribe(() => this.setVisibility(false));|
|
||
| tabGroup.selectedIndex = 2; | ||
| fixture.detectChanges(); | ||
| fixture.whenStable().then(() => { |
There was a problem hiding this comment.
Add comment why whenStable is needed
| @@ -0,0 +1,44 @@ | |||
| import {Component} from '@angular/core'; | |||
There was a problem hiding this comment.
Not sure why the extra test is needed, isn't this covered by tab-group.spec.ts?
There was a problem hiding this comment.
It was not caught by the current tests in tab-group.spec.ts, would you prefer I move it into tab-group.spec.ts?
|
|
||
| /** Whether the provided position state is considered center, regardless of origin. */ | ||
| private _isCenterPosition(position: MdTabBodyPositionState|string): boolean { | ||
| _isCenterPosition(position: MdTabBodyPositionState|string): boolean { |
There was a problem hiding this comment.
Will need to remove the underscore if it's not private.
andrewseguin
left a comment
There was a problem hiding this comment.
LGTM - nice work, takes a lot to get a good hold of all the change detection pieces happening in the tabs component
|
Add |
|
|
||
| constructor( | ||
| _componentFactoryResolver: ComponentFactoryResolver, | ||
| _viewContainerRef: ViewContainerRef, |
There was a problem hiding this comment.
@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
4dfdf85 to
d587250
Compare
|
@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 Issue resolved. |
|
@josephperrott - Can you rebase? |
2a8a5e8 to
b894fe8
Compare
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Related to #6832
By moving the entrance logic into the
MdTabBodyPortalsetting up the content after change detection is avoided.Fixes #7032 #7061