@@ -117,15 +117,17 @@ export const SELECT_PANEL_INDENT_PADDING_X = SELECT_PANEL_PADDING_X * 2;
117
117
/** The height of the select items in `em` units. */
118
118
export const SELECT_ITEM_HEIGHT_EM = 3 ;
119
119
120
+ // TODO(josephperrott): Revert to a constant after 2018 spec updates are fully merged.
120
121
/**
121
122
* Distance between the panel edge and the option text in
122
123
* multi-selection mode.
123
124
*
125
+ * Calculated as:
124
126
* (SELECT_PANEL_PADDING_X * 1.5) + 20 = 44
125
127
* The padding is multiplied by 1.5 because the checkbox's margin is half the padding.
126
128
* The checkbox width is 20px.
127
129
*/
128
- export const SELECT_MULTIPLE_PANEL_PADDING_X = SELECT_PANEL_PADDING_X * 1.5 + 20 ;
130
+ export let SELECT_MULTIPLE_PANEL_PADDING_X = 0 ;
129
131
130
132
/**
131
133
* The select panel will only "fit" inside the viewport if it is positioned at
@@ -764,6 +766,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
764
766
*/
765
767
_onAttached ( ) : void {
766
768
this . overlayDir . positionChange . pipe ( take ( 1 ) ) . subscribe ( ( ) => {
769
+ this . _setPseudoCheckboxPaddingSize ( ) ;
767
770
this . _changeDetectorRef . detectChanges ( ) ;
768
771
this . _calculateOverlayOffsetX ( ) ;
769
772
this . panel . nativeElement . scrollTop = this . _scrollTop ;
@@ -775,6 +778,17 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
775
778
return this . _parentFormField ? `mat-${ this . _parentFormField . color } ` : '' ;
776
779
}
777
780
781
+ // TODO(josephperrott): Remove after 2018 spec updates are fully merged.
782
+ /** Sets the pseudo checkbox padding size based on the width of the pseudo checkbox. */
783
+ private _setPseudoCheckboxPaddingSize ( ) {
784
+ if ( ! SELECT_MULTIPLE_PANEL_PADDING_X && this . multiple ) {
785
+ const pseudoCheckbox = this . panel . nativeElement . querySelector ( '.mat-pseudo-checkbox' ) ;
786
+ if ( pseudoCheckbox ) {
787
+ SELECT_MULTIPLE_PANEL_PADDING_X = SELECT_PANEL_PADDING_X * 1.5 + pseudoCheckbox . offsetWidth ;
788
+ }
789
+ }
790
+ }
791
+
778
792
/** Whether the select has a value. */
779
793
get empty ( ) : boolean {
780
794
return ! this . _selectionModel || this . _selectionModel . isEmpty ( ) ;
0 commit comments