-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
bug(tabs): fix arrows not showing on reszize #6303 #6304
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ import { | |
NgZone, | ||
Renderer2, | ||
ChangeDetectionStrategy, | ||
ChangeDetectorRef, | ||
ChangeDetectorRef | ||
} from '@angular/core'; | ||
import { | ||
RIGHT_ARROW, | ||
|
@@ -40,7 +40,7 @@ import {of as observableOf} from 'rxjs/observable/of'; | |
import {merge} from 'rxjs/observable/merge'; | ||
import {fromEvent} from 'rxjs/observable/fromEvent'; | ||
import {CanDisableRipple, mixinDisableRipple} from '../core/common-behaviors/disable-ripple'; | ||
|
||
import {RxChain, debounceTime} from '@angular/cdk/rxjs'; | ||
|
||
/** | ||
* The directions that scrolling can go in when the header's tabs exceed the header width. 'After' | ||
|
@@ -78,7 +78,7 @@ export const _MdTabHeaderMixinBase = mixinDisableRipple(MdTabHeaderBase); | |
host: { | ||
'class': 'mat-tab-header', | ||
'[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls', | ||
'[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'", | ||
'[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TrailingCommas4Life There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you serial?! |
||
} | ||
}) | ||
export class MdTabHeader extends _MdTabHeaderMixinBase | ||
|
@@ -121,6 +121,9 @@ export class MdTabHeader extends _MdTabHeaderMixinBase | |
|
||
private _selectedIndex: number = 0; | ||
|
||
/** subscription for the window resize handler */ | ||
private _resizeSubscription: Subscription | null; | ||
|
||
/** The index of the active tab. */ | ||
@Input() | ||
get selectedIndex(): number { return this._selectedIndex; } | ||
|
@@ -143,6 +146,11 @@ export class MdTabHeader extends _MdTabHeaderMixinBase | |
private _changeDetectorRef: ChangeDetectorRef, | ||
@Optional() private _dir: Directionality) { | ||
super(); | ||
|
||
// TODO: Add library level window listener https://goo.gl/FJWhZM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you got the wrong comment in your shortlink |
||
this._resizeSubscription = RxChain.from(fromEvent(window, 'resize')) | ||
.call(debounceTime, 150) | ||
.subscribe(() => this._checkPaginationEnabled()); | ||
} | ||
|
||
ngAfterContentChecked(): void { | ||
|
@@ -208,6 +216,11 @@ export class MdTabHeader extends _MdTabHeaderMixinBase | |
this._realignInkBar.unsubscribe(); | ||
this._realignInkBar = null; | ||
} | ||
|
||
if (this._resizeSubscription) { | ||
this._resizeSubscription.unsubscribe(); | ||
this._resizeSubscription = null; | ||
} | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I generally prefer tests that assert on the outcome of calling the function rather than using a spy. In this case, though, it would end up being a brittle geometric value so the spy is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, thats what I was thinking too.