Skip to content

Commit 4a2ac08

Browse files
josephperrottandrewseguin
authored andcommitted
cleanup(select): remove runtime checkbox padding calculation workaround (#16827)
(cherry picked from commit b0495f6)
1 parent 6fa4c81 commit 4a2ac08

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

src/material/select/select.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ export const SELECT_ITEM_HEIGHT_EM = 3;
119119
* multi-selection mode.
120120
*
121121
* Calculated as:
122-
* (SELECT_PANEL_PADDING_X * 1.5) + 20 = 44
122+
* (SELECT_PANEL_PADDING_X * 1.5) + 16 = 40
123123
* The padding is multiplied by 1.5 because the checkbox's margin is half the padding.
124124
* The checkbox width is 16px.
125125
*/
126-
export let SELECT_MULTIPLE_PANEL_PADDING_X = 0;
126+
export const SELECT_MULTIPLE_PANEL_PADDING_X = SELECT_PANEL_PADDING_X * 1.5 + 16;
127127

128128
/**
129129
* The select panel will only "fit" inside the viewport if it is positioned at
@@ -805,7 +805,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
805805
*/
806806
_onAttached(): void {
807807
this.overlayDir.positionChange.pipe(take(1)).subscribe(() => {
808-
this._setPseudoCheckboxPaddingSize();
809808
this._changeDetectorRef.detectChanges();
810809
this._calculateOverlayOffsetX();
811810
this.panel.nativeElement.scrollTop = this._scrollTop;
@@ -817,17 +816,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
817816
return this._parentFormField ? `mat-${this._parentFormField.color}` : '';
818817
}
819818

820-
// TODO(josephperrott): Remove after 2018 spec updates are fully merged.
821-
/** Sets the pseudo checkbox padding size based on the width of the pseudo checkbox. */
822-
private _setPseudoCheckboxPaddingSize() {
823-
if (!SELECT_MULTIPLE_PANEL_PADDING_X && this.multiple) {
824-
const pseudoCheckbox = this.panel.nativeElement.querySelector('.mat-pseudo-checkbox');
825-
if (pseudoCheckbox) {
826-
SELECT_MULTIPLE_PANEL_PADDING_X = SELECT_PANEL_PADDING_X * 1.5 + pseudoCheckbox.offsetWidth;
827-
}
828-
}
829-
}
830-
831819
/** Whether the select has a value. */
832820
get empty(): boolean {
833821
return !this._selectionModel || this._selectionModel.isEmpty();

tools/public_api_guard/material/select.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export declare class MatSelectTrigger {
114114

115115
export declare const SELECT_ITEM_HEIGHT_EM = 3;
116116

117-
export declare let SELECT_MULTIPLE_PANEL_PADDING_X: number;
117+
export declare const SELECT_MULTIPLE_PANEL_PADDING_X: number;
118118

119119
export declare const SELECT_PANEL_INDENT_PADDING_X: number;
120120

0 commit comments

Comments
 (0)