Skip to content

Commit 8922d45

Browse files
committed
test: fix datepicker position tests failing in firefox v78
The datepicker position tests seem to be thrown off in Firefox v78 where inputs have an uneven width (resulting in subpixel rendering that is not predictable and stable enough for our test assertions)
1 parent 8a887d2 commit 8922d45

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/material/datepicker/datepicker.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,21 @@ describe('MatDatepicker', () => {
19291929

19301930
});
19311931

1932+
/**
1933+
* Styles that set input elements to a fixed width. This helps with client rect measurements
1934+
* (i.e. that the datepicker aligns properly). Inputs have different dimensions in different
1935+
* browsers. e.g. in Firefox the input width is uneven, causing unexpected deviations in measuring.
1936+
* Note: The input should be able to shrink as on iOS the viewport width is very little but the
1937+
* datepicker inputs should not leave the viewport (as that throws off measuring too).
1938+
*/
1939+
const inputFixedWidthStyles = `
1940+
input {
1941+
width: 100%;
1942+
max-width: 150px;
1943+
border: none;
1944+
box-sizing: border-box;
1945+
}
1946+
`;
19321947

19331948
@Component({
19341949
template: `
@@ -1941,6 +1956,7 @@ describe('MatDatepicker', () => {
19411956
[xPosition]="xPosition"
19421957
[yPosition]="yPosition"></mat-datepicker>
19431958
`,
1959+
styles: [inputFixedWidthStyles]
19441960
})
19451961
class StandardDatepicker {
19461962
opened = false;

0 commit comments

Comments
 (0)