Skip to content

fix(dialog): dialogs that hit max-width not centered on IE #8055

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

Merged
merged 1 commit into from
Jan 12, 2018
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
3 changes: 3 additions & 0 deletions src/cdk/overlay/_overlay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
display: flex;
position: absolute;
z-index: $cdk-z-index-overlay;

// Fixes issues where overlays are centered on IE when they hit the max-width.
flex-direction: column;
}

// A single overlay pane.
Expand Down
16 changes: 8 additions & 8 deletions src/cdk/overlay/position/global-position-strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('GlobalPositonStrategy', () => {
expect(elementStyle.marginBottom).toBe('');
expect(elementStyle.marginRight).toBe('');

expect(parentStyle.justifyContent).toBe('flex-start');
expect(parentStyle.alignItems).toBe('flex-start');
expect(parentStyle.justifyContent).toBe('flex-start');
});

it('should position the element to the (bottom, right) with an offset', () => {
Expand All @@ -44,8 +44,8 @@ describe('GlobalPositonStrategy', () => {
expect(elementStyle.marginBottom).toBe('70px');
expect(elementStyle.marginRight).toBe('15em');

expect(parentStyle.justifyContent).toBe('flex-end');
expect(parentStyle.alignItems).toBe('flex-end');
expect(parentStyle.justifyContent).toBe('flex-end');
});

it('should overwrite previously applied positioning', () => {
Expand All @@ -60,8 +60,8 @@ describe('GlobalPositonStrategy', () => {
expect(elementStyle.marginBottom).toBe('');
expect(elementStyle.marginRight).toBe('');

expect(parentStyle.justifyContent).toBe('flex-start');
expect(parentStyle.alignItems).toBe('flex-start');
expect(parentStyle.justifyContent).toBe('flex-start');

strategy.bottom('70px').right('15em').apply();

Expand All @@ -70,17 +70,17 @@ describe('GlobalPositonStrategy', () => {
expect(element.style.marginBottom).toBe('70px');
expect(element.style.marginRight).toBe('15em');

expect(parentStyle.justifyContent).toBe('flex-end');
expect(parentStyle.alignItems).toBe('flex-end');
expect(parentStyle.justifyContent).toBe('flex-end');
});

it('should center the element', () => {
strategy.centerHorizontally().centerVertically().apply();

let parentStyle = (element.parentNode as HTMLElement).style;

expect(parentStyle.justifyContent).toBe('center');
expect(parentStyle.alignItems).toBe('center');
expect(parentStyle.justifyContent).toBe('center');
});

it('should center the element with an offset', () => {
Expand All @@ -92,8 +92,8 @@ describe('GlobalPositonStrategy', () => {
expect(elementStyle.marginLeft).toBe('10px');
expect(elementStyle.marginTop).toBe('15px');

expect(parentStyle.justifyContent).toBe('center');
expect(parentStyle.alignItems).toBe('center');
expect(parentStyle.justifyContent).toBe('center');
});

it('should make the element position: static', () => {
Expand Down Expand Up @@ -137,13 +137,13 @@ describe('GlobalPositonStrategy', () => {
strategy.centerHorizontally().width('100%').apply();

expect(element.style.marginLeft).toBe('0px');
expect((element.parentNode as HTMLElement).style.justifyContent).toBe('flex-start');
expect((element.parentNode as HTMLElement).style.alignItems).toBe('flex-start');
});

it('should reset the vertical position and offset when the height is 100%', () => {
strategy.centerVertically().height('100%').apply();

expect(element.style.marginTop).toBe('0px');
expect((element.parentNode as HTMLElement).style.alignItems).toBe('flex-start');
expect((element.parentNode as HTMLElement).style.justifyContent).toBe('flex-start');
});
});
12 changes: 6 additions & 6 deletions src/cdk/overlay/position/global-position-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
top(value: string = ''): this {
this._bottomOffset = '';
this._topOffset = value;
this._alignItems = 'flex-start';
this._justifyContent = 'flex-start';
return this;
}

Expand All @@ -57,7 +57,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
left(value: string = ''): this {
this._rightOffset = '';
this._leftOffset = value;
this._justifyContent = 'flex-start';
this._alignItems = 'flex-start';
return this;
}

Expand All @@ -68,7 +68,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
bottom(value: string = ''): this {
this._topOffset = '';
this._bottomOffset = value;
this._alignItems = 'flex-end';
this._justifyContent = 'flex-end';
return this;
}

Expand All @@ -79,7 +79,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
right(value: string = ''): this {
this._leftOffset = '';
this._rightOffset = value;
this._justifyContent = 'flex-end';
this._alignItems = 'flex-end';
return this;
}

Expand Down Expand Up @@ -123,7 +123,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
*/
centerHorizontally(offset: string = ''): this {
this.left(offset);
this._justifyContent = 'center';
this._alignItems = 'center';
return this;
}

Expand All @@ -135,7 +135,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
*/
centerVertically(offset: string = ''): this {
this.top(offset);
this._alignItems = 'center';
this._justifyContent = 'center';
return this;
}

Expand Down