Skip to content

Commit fe8db1e

Browse files
committed
fix(dialog): dialogs that hit max-width not centered on IE
Fixes dialogs that hit their `max-width` no longer being centered in IE11. This seems like a regression introduced after 57f19cd.
1 parent 0ea4370 commit fe8db1e

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/cdk/overlay/_overlay.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
3939
display: flex;
4040
position: absolute;
4141
z-index: $cdk-z-index-overlay;
42+
43+
// Fixes issues where overlays are centered on IE when they hit the max-width.
44+
flex-direction: column;
4245
}
4346

4447
// A single overlay pane.

src/cdk/overlay/position/global-position-strategy.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ describe('GlobalPositonStrategy', () => {
2929
expect(elementStyle.marginBottom).toBe('');
3030
expect(elementStyle.marginRight).toBe('');
3131

32-
expect(parentStyle.justifyContent).toBe('flex-start');
3332
expect(parentStyle.alignItems).toBe('flex-start');
33+
expect(parentStyle.justifyContent).toBe('flex-start');
3434
});
3535

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

47-
expect(parentStyle.justifyContent).toBe('flex-end');
4847
expect(parentStyle.alignItems).toBe('flex-end');
48+
expect(parentStyle.justifyContent).toBe('flex-end');
4949
});
5050

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

63-
expect(parentStyle.justifyContent).toBe('flex-start');
6463
expect(parentStyle.alignItems).toBe('flex-start');
64+
expect(parentStyle.justifyContent).toBe('flex-start');
6565

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

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

73-
expect(parentStyle.justifyContent).toBe('flex-end');
7473
expect(parentStyle.alignItems).toBe('flex-end');
74+
expect(parentStyle.justifyContent).toBe('flex-end');
7575
});
7676

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

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

82-
expect(parentStyle.justifyContent).toBe('center');
8382
expect(parentStyle.alignItems).toBe('center');
83+
expect(parentStyle.justifyContent).toBe('center');
8484
});
8585

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

95-
expect(parentStyle.justifyContent).toBe('center');
9695
expect(parentStyle.alignItems).toBe('center');
96+
expect(parentStyle.justifyContent).toBe('center');
9797
});
9898

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

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

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

146146
expect(element.style.marginTop).toBe('0px');
147-
expect((element.parentNode as HTMLElement).style.alignItems).toBe('flex-start');
147+
expect((element.parentNode as HTMLElement).style.justifyContent).toBe('flex-start');
148148
});
149149
});

src/cdk/overlay/position/global-position-strategy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
4444
top(value: string = ''): this {
4545
this._bottomOffset = '';
4646
this._topOffset = value;
47-
this._alignItems = 'flex-start';
47+
this._justifyContent = 'flex-start';
4848
return this;
4949
}
5050

@@ -55,7 +55,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
5555
left(value: string = ''): this {
5656
this._rightOffset = '';
5757
this._leftOffset = value;
58-
this._justifyContent = 'flex-start';
58+
this._alignItems = 'flex-start';
5959
return this;
6060
}
6161

@@ -66,7 +66,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
6666
bottom(value: string = ''): this {
6767
this._topOffset = '';
6868
this._bottomOffset = value;
69-
this._alignItems = 'flex-end';
69+
this._justifyContent = 'flex-end';
7070
return this;
7171
}
7272

@@ -77,7 +77,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
7777
right(value: string = ''): this {
7878
this._leftOffset = '';
7979
this._rightOffset = value;
80-
this._justifyContent = 'flex-end';
80+
this._alignItems = 'flex-end';
8181
return this;
8282
}
8383

@@ -121,7 +121,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
121121
*/
122122
centerHorizontally(offset: string = ''): this {
123123
this.left(offset);
124-
this._justifyContent = 'center';
124+
this._alignItems = 'center';
125125
return this;
126126
}
127127

@@ -133,7 +133,7 @@ export class GlobalPositionStrategy implements PositionStrategy {
133133
*/
134134
centerVertically(offset: string = ''): this {
135135
this.top(offset);
136-
this._alignItems = 'center';
136+
this._justifyContent = 'center';
137137
return this;
138138
}
139139

0 commit comments

Comments
 (0)