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

bug(tabs): fix arrows not showing on reszize #6303 #6304

Merged
merged 4 commits into from
Aug 9, 2017

Conversation

amcdnl
Copy link
Contributor

@amcdnl amcdnl commented Aug 6, 2017

Addresses #6303

@amcdnl amcdnl self-assigned this Aug 6, 2017
@amcdnl amcdnl requested a review from jelbourn August 6, 2017 15:03
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 6, 2017
@@ -387,6 +388,7 @@ export class MdTabHeader extends _MdTabHeaderMixinBase
* This is an expensive call that forces a layout reflow to compute box and scroll metrics and
* should be called sparingly.
*/
@HostListener('window:resize')
Copy link
Member

@crisbeto crisbeto Aug 6, 2017

Choose a reason for hiding this comment

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

We don't really use the @HostListener anywhere. Can you switch to using the host property on the component definition instead?

Copy link
Contributor Author

@amcdnl amcdnl Aug 6, 2017

Choose a reason for hiding this comment

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

Done.

crisbeto added a commit to crisbeto/material2 that referenced this pull request Aug 6, 2017
Adds the `HostBinding` and `HostListener` decorators to the banned symbols list for consistency's sake. Refactors the handful of places that were using them.

Relates to angular#6304.
@@ -79,6 +80,7 @@ export const _MdTabHeaderMixinBase = mixinDisableRipple(MdTabHeaderBase);
'class': 'mat-tab-header',
'[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls',
'[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'",
'(window:resize)': "_checkPaginationEnabled()"
Copy link
Member

Choose a reason for hiding this comment

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

At the very least this call should be debounced. The comment for the handler even says "This is an expensive call that forces a layout reflow to compute box and scroll metrics and should be called sparingly."

@@ -79,6 +80,7 @@ export const _MdTabHeaderMixinBase = mixinDisableRipple(MdTabHeaderBase);
'class': 'mat-tab-header',
'[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls',
'[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'",
'(window:resize)': "_checkPaginationEnabled()"
Copy link
Member

Choose a reason for hiding this comment

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

We should really just have one library-wide resize handler instead of each component adding their own. Add a TODO?

@@ -79,6 +80,7 @@ export const _MdTabHeaderMixinBase = mixinDisableRipple(MdTabHeaderBase);
'class': 'mat-tab-header',
'[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls',
'[class.mat-tab-header-rtl]': "_getLayoutDirection() == 'rtl'",
'(window:resize)': "_checkPaginationEnabled()"
Copy link
Member

Choose a reason for hiding this comment

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

Any way to add a unit test for this?

mmalerba pushed a commit that referenced this pull request Aug 7, 2017
Adds the `HostBinding` and `HostListener` decorators to the banned symbols list for consistency's sake. Refactors the handful of places that were using them.

Relates to #6304.
mmalerba pushed a commit that referenced this pull request Aug 7, 2017
Adds the `HostBinding` and `HostListener` decorators to the banned symbols list for consistency's sake. Refactors the handful of places that were using them.

Relates to #6304.
@amcdnl
Copy link
Contributor Author

amcdnl commented Aug 7, 2017

@jelbourn - Ready for another review.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple minor things. Add the "merge-ready" label when ready

tick(10);
fixture.detectChanges();

expect(header._checkPaginationEnabled).toHaveBeenCalled();
Copy link
Member

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.

Copy link
Contributor Author

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.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

I think you got the wrong comment in your shortlink
(probably meant #6304 (comment))

@@ -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'"
Copy link
Member

Choose a reason for hiding this comment

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

TrailingCommas4Life

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you serial?!

@jelbourn
Copy link
Member

jelbourn commented Aug 8, 2017

Actually I just noticed that this breaks the prerender task. The resize event should only be setup when on the browser platform

@amcdnl
Copy link
Contributor Author

amcdnl commented Aug 8, 2017

@jelbourn - ready for another review.

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Aug 8, 2017
@mmalerba mmalerba merged commit f96ffeb into angular:master Aug 9, 2017
@amcdnl amcdnl deleted the tab-arrows-resize branch August 12, 2017 14:06
crisbeto added a commit to crisbeto/material2 that referenced this pull request Aug 12, 2017
In angular#6304, an extra window resize handler was added in order to call `_checkPaginationEnabled`. This handler is unnecessary, because we have another resize handler a little bit below that calls `_updatePagination`, which will call `_checkPaginationEnabled` internally. The original issue that angular#6304 was fixing was due to the fact that the current listener wasn't being run in the Angular zone. These changes remove the extra listener, increase the debounce interval and move the handler outside back into the zone. There may be a slight overhead from moving the listener into the zone, however it should be offset by not having another listener and not calling `_checkPaginationEnabled` twice.
andrewseguin pushed a commit that referenced this pull request Aug 15, 2017
In #6304, an extra window resize handler was added in order to call `_checkPaginationEnabled`. This handler is unnecessary, because we have another resize handler a little bit below that calls `_updatePagination`, which will call `_checkPaginationEnabled` internally. The original issue that #6304 was fixing was due to the fact that the current listener wasn't being run in the Angular zone. These changes remove the extra listener, increase the debounce interval and move the handler outside back into the zone. There may be a slight overhead from moving the listener into the zone, however it should be offset by not having another listener and not calling `_checkPaginationEnabled` twice.
@angular-automatic-lock-bot
Copy link

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 6, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants