mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(GlobalPositionStrategy): justifyContent center ignored when direction is RTL (#11877)
This commit is contained in:
committed by
Joey Perrott
parent
d5de711639
commit
415c956184
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user