Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/cdk/overlay/position/global-position-strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 2 additions & 0 deletions src/cdk/overlay/position/global-position-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Member

Choose a reason for hiding this comment

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

nit: the indentation here is too much.

} 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
Expand Down