Skip to content

Commit 557ac0d

Browse files
authored
fix(material-experimental/mdc-select): change max height to show scrollability (#24129)
Increases the maximum height of the MDC-based select panel in order to partially show the next option so that it is easier to see when the panel is scrollable. Related to b/211518654.
1 parent 3f727a2 commit 557ac0d

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/material-experimental/mdc-select/select.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
$mat-select-arrow-size: 5px !default;
99
$mat-select-arrow-margin: 4px !default;
10-
$mat-select-panel-max-height: 256px !default;
10+
$mat-select-panel-max-height: 275px !default;
1111
$mat-select-placeholder-arrow-space: 2 *
1212
($mat-select-arrow-size + $mat-select-arrow-margin);
1313
$leading-width: 12px !default;

src/material-experimental/mdc-select/select.spec.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,9 +2237,8 @@ describe('MDC-based MatSelect', () => {
22372237
dispatchKeyboardEvent(host, 'keydown', DOWN_ARROW);
22382238
}
22392239

2240-
// <top padding> + <option index * height> - <panel height> = 8 + 16 * 48 - 256 = 520
2241-
// <top padding> + <option index * height> - <panel height> = 8 + 16 * 48 - 256 = 520
2242-
expect(panel.scrollTop).withContext('Expected scroll to be at the 16th option.').toBe(520);
2240+
// <top padding> + <option index * height> - <panel height> = 8 + 16 * 48 - 275 = 501
2241+
expect(panel.scrollTop).withContext('Expected scroll to be at the 16th option.').toBe(501);
22432242
}));
22442243

22452244
it('should scroll up to the active option', fakeAsync(() => {
@@ -2252,7 +2251,6 @@ describe('MDC-based MatSelect', () => {
22522251
dispatchKeyboardEvent(host, 'keydown', UP_ARROW);
22532252
}
22542253

2255-
// <top padding> + <option index * height> = 8 + 9 * 48 = 440
22562254
// <top padding> + <option index * height> = 8 + 9 * 48 = 440
22572255
expect(panel.scrollTop).withContext('Expected scroll to be at the 9th option.').toBe(440);
22582256
}));
@@ -2277,12 +2275,8 @@ describe('MDC-based MatSelect', () => {
22772275
// Note that we press down 5 times, but it will skip
22782276
// 3 options because the second group is disabled.
22792277
// <top padding> + <(option index + group labels) * height> - <panel height> =
2280-
// 8 + (9 + 3) * 48 - 256 = 328
2281-
// Note that we press down 5 times, but it will skip
2282-
// 3 options because the second group is disabled.
2283-
// <top padding> + <(option index + group labels) * height> - <panel height> =
2284-
// 8 + (9 + 3) * 48 - 256 = 328
2285-
expect(panel.scrollTop).withContext('Expected scroll to be at the 9th option.').toBe(328);
2278+
// 8 + (9 + 3) * 48 - 275 = 309
2279+
expect(panel.scrollTop).withContext('Expected scroll to be at the 9th option.').toBe(309);
22862280
}));
22872281

22882282
it('should scroll to the top when pressing HOME', fakeAsync(() => {
@@ -2298,7 +2292,6 @@ describe('MDC-based MatSelect', () => {
22982292
dispatchKeyboardEvent(host, 'keydown', HOME);
22992293
fixture.detectChanges();
23002294

2301-
// 8px is the top padding of the panel.
23022295
// 8px is the top padding of the panel.
23032296
expect(panel.scrollTop).withContext('Expected panel to be scrolled to the top').toBe(8);
23042297
}));
@@ -2308,12 +2301,10 @@ describe('MDC-based MatSelect', () => {
23082301
fixture.detectChanges();
23092302

23102303
// <top padding> + <option amount> * <option height> - <panel height> =
2311-
// 8 + 30 * 48 - 256 = 1192
2312-
// <top padding> + <option amount> * <option height> - <panel height> =
2313-
// 8 + 30 * 48 - 256 = 1192
2304+
// 8 + 30 * 48 - 275 = 1173
23142305
expect(panel.scrollTop)
23152306
.withContext('Expected panel to be scrolled to the bottom')
2316-
.toBe(1192);
2307+
.toBe(1173);
23172308
}));
23182309

23192310
it('should scroll to the active option when typing', fakeAsync(() => {
@@ -2325,9 +2316,8 @@ describe('MDC-based MatSelect', () => {
23252316
}
23262317
flush();
23272318

2328-
// <top padding> + <option index * height> - <panel height> = 8 + 16 * 48 - 256 = 520
2329-
// <top padding> + <option index * height> - <panel height> = 8 + 16 * 48 - 256 = 520
2330-
expect(panel.scrollTop).withContext('Expected scroll to be at the 16th option.').toBe(520);
2319+
// <top padding> + <option index * height> - <panel height> = 8 + 16 * 48 - 275 = 501
2320+
expect(panel.scrollTop).withContext('Expected scroll to be at the 16th option.').toBe(501);
23312321
}));
23322322

23332323
it('should scroll to top when going to first option in top group', fakeAsync(() => {

0 commit comments

Comments
 (0)