Skip to content

Commit e721664

Browse files
crisbetoVivian Hu
authored and
Vivian Hu
committedJan 18, 2019
fix(tabs): pagination not working correctly on chrome in rtl mode (#14690)
In #13223 we added some code that resets the scroll position of the tab header, in order to fix a bug on IE and Edge. The changes seem to have introduced an issue on newer Chrome versions in RTL mode where the transform gets negated and the header content doesn't move. These changes scope the fix only to IE and Edge. Fixes #14689.
1 parent 6fd84dc commit e721664

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed
 

‎src/lib/tabs/tab-header.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {takeUntil} from 'rxjs/operators';
3434
import {MatInkBar} from './ink-bar';
3535
import {MatTabLabelWrapper} from './tab-label-wrapper';
3636
import {FocusKeyManager} from '@angular/cdk/a11y';
37+
import {Platform} from '@angular/cdk/platform';
3738

3839

3940
/**
@@ -141,8 +142,9 @@ export class MatTabHeader extends _MatTabHeaderMixinBase
141142
private _changeDetectorRef: ChangeDetectorRef,
142143
private _viewportRuler: ViewportRuler,
143144
@Optional() private _dir: Directionality,
144-
// @breaking-change 8.0.0 `_ngZone` parameter to be made required.
145-
private _ngZone?: NgZone) {
145+
// @breaking-change 8.0.0 `_ngZone` and `_platforms` parameters to be made required.
146+
private _ngZone?: NgZone,
147+
private _platform?: Platform) {
146148
super();
147149
}
148150

@@ -332,6 +334,7 @@ export class MatTabHeader extends _MatTabHeaderMixinBase
332334
/** Performs the CSS transformation on the tab list that will cause the list to scroll. */
333335
_updateTabScrollPosition() {
334336
const scrollDistance = this.scrollDistance;
337+
const platform = this._platform;
335338
const translateX = this._getLayoutDirection() === 'ltr' ? -scrollDistance : scrollDistance;
336339

337340
// Don't use `translate3d` here because we don't want to create a new layer. A new layer
@@ -344,8 +347,12 @@ export class MatTabHeader extends _MatTabHeaderMixinBase
344347

345348
// Setting the `transform` on IE will change the scroll offset of the parent, causing the
346349
// position to be thrown off in some cases. We have to reset it ourselves to ensure that
347-
// it doesn't get thrown off.
348-
this._tabListContainer.nativeElement.scrollLeft = 0;
350+
// it doesn't get thrown off. Note that we scope it only to IE and Edge, because messing
351+
// with the scroll position throws off Chrome 71+ in RTL mode (see #14689).
352+
// @breaking-change 8.0.0 Remove null check for `platform`.
353+
if (platform && (platform.TRIDENT || platform.EDGE)) {
354+
this._tabListContainer.nativeElement.scrollLeft = 0;
355+
}
349356
}
350357

351358
/** Sets the distance in pixels that the tab header should be transformed in the X-axis. */

0 commit comments

Comments
 (0)
Please sign in to comment.