fix(GlobalPositionStrategy): justifyContent center ignored when direction is RTL (#11877)

This commit is contained in:
Leibale Eidelman
2018-06-29 19:34:43 +03:00
committed by Joey Perrott
parent d5de711639
commit 415c956184
2 changed files with 16 additions and 0 deletions
@@ -270,6 +270,20 @@ describe('GlobalPositonStrategy', () => {
expect(elementStyle.height).toBe('300px');
});
it('should center the element in RTL', () => {
attachOverlay({
direction: 'rtl',
positionStrategy: overlay.position()
.global()
.centerHorizontally()
.centerVertically()
});
const parentStyle = (overlayRef.overlayElement.parentNode as HTMLElement).style;
expect(parentStyle.justifyContent).toBe('center');
expect(parentStyle.alignItems).toBe('center');
});
it('should invert `justify-content` when using `left` in RTL', () => {
attachOverlay({
positionStrategy: overlay.position().global().left('0'),
@@ -169,6 +169,8 @@ export class GlobalPositionStrategy implements PositionStrategy {
if (config.width === '100%') {
parentStyles.justifyContent = 'flex-start';
} else if (this._justifyContent === 'center') {
parentStyles.justifyContent = 'center';
} else if (this._overlayRef.getConfig().direction === 'rtl') {
// In RTL the browser will invert `flex-start` and `flex-end` automatically, but we
// don't want that because our positioning is explicitly `left` and `right`, hence