File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,15 @@ const collection = new MaterialCollection<KnobTypesToKnobs<StoryKnobs>>(
35
35
new Knob ( 'disabled' , { ui : boolInput ( ) , defaultValue : false } ) ,
36
36
new Knob ( 'errorText' , { ui : textInput ( ) , defaultValue : '' } ) ,
37
37
new Knob ( 'supportingText' , { ui : textInput ( ) , defaultValue : '' } ) ,
38
+ new Knob ( 'menuAlign' , {
39
+ defaultValue : 'start' as const ,
40
+ ui : selectDropdown < 'start' | 'end' > ( {
41
+ options : [
42
+ { label : 'start' , value : 'start' } ,
43
+ { label : 'end' , value : 'end' } ,
44
+ ] ,
45
+ } ) ,
46
+ } ) ,
38
47
new Knob ( 'menuPositioning' , {
39
48
defaultValue : 'popover' as const ,
40
49
ui : selectDropdown < 'absolute' | 'fixed' | 'popover' > ( {
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export interface StoryKnobs {
24
24
supportingText : string ;
25
25
error : boolean ;
26
26
clampMenuWidth : boolean ;
27
+ menuAlign : 'start' | 'end' | undefined ;
27
28
menuPositioning : 'absolute' | 'fixed' | 'popover' | undefined ;
28
29
29
30
'md-select Slots' : void ;
@@ -35,15 +36,18 @@ const selects: MaterialStoryInit<StoryKnobs> = {
35
36
name : 'Selects' ,
36
37
render ( knobs ) {
37
38
return html `
38
- < div style ="display: flex; gap: 16px ">
39
+ < div
40
+ style ="display: flex; gap: 16px;flex-direction: column;align-items:end;border: 1px solid black; ">
39
41
< md-filled-select
42
+ style ="min-width: 100px;width: fit-content; "
40
43
.label =${ knobs . label }
41
44
.quick =${ knobs . quick }
42
45
.required=${ knobs . required }
43
46
.disabled=${ knobs . disabled }
44
47
.errorText=${ knobs . errorText }
45
48
.supportingText=${ knobs . supportingText }
46
49
.clampMenuWidth=${ knobs . clampMenuWidth }
50
+ .menuAlign=${ knobs . menuAlign ! }
47
51
.menuPositioning=${ knobs . menuPositioning ! }
48
52
.typeaheadDelay=${ knobs . typeaheadDelay }
49
53
.error=${ knobs . error } >
@@ -60,6 +64,7 @@ const selects: MaterialStoryInit<StoryKnobs> = {
60
64
.errorText=${ knobs . errorText }
61
65
.supportingText=${ knobs . supportingText }
62
66
.clampMenuWidth=${ knobs . clampMenuWidth }
67
+ .menuAlign=${ knobs . menuAlign ! }
63
68
.menuPositioning=${ knobs . menuPositioning ! }
64
69
.typeaheadDelay=${ knobs . typeaheadDelay }
65
70
.error=${ knobs . error } >
Original file line number Diff line number Diff line change @@ -153,6 +153,12 @@ export abstract class Select extends selectBaseClass {
153
153
*/
154
154
@property ( { attribute : 'display-text' } ) displayText = '' ;
155
155
156
+ /**
157
+ * Whether the menu should be aligned to the start or the end of the select's
158
+ * textbox.
159
+ */
160
+ @property ( { attribute : 'menu-align' } ) menuAlign : 'start' | 'end' = 'start' ;
161
+
156
162
/**
157
163
* The value of the currently selected option.
158
164
*
@@ -478,6 +484,8 @@ export abstract class Select extends selectBaseClass {
478
484
.quick=${ this . quick }
479
485
.positioning=${ this . menuPositioning }
480
486
.typeaheadDelay=${ this . typeaheadDelay }
487
+ .anchorCorner=${ this . menuAlign === 'start' ? 'end-start' : 'end-end' }
488
+ .menuCorner=${ this . menuAlign === 'start' ? 'start-start' : 'start-end' }
481
489
@opening=${ this . handleOpening }
482
490
@opened=${ this . redispatchEvent }
483
491
@closing=${ this . redispatchEvent }
You can’t perform that action at this time.
0 commit comments