File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -135,6 +135,28 @@ describe('SolidUICombobox', () => {
135135 } )
136136 } )
137137
138+ it ( 'opens the popup when clicking the dropdown toggle button' , async ( ) => {
139+ const combobox = new Combobox ( )
140+ combobox . options = [
141+ { label : 'Alice' , value : 'alice' } ,
142+ { label : 'Bob' , value : 'bob' }
143+ ]
144+
145+ document . body . appendChild ( combobox )
146+ await combobox . updateComplete
147+
148+ const toggle = combobox . shadowRoot ?. querySelector ( 'button.dropdown-toggle' ) as HTMLButtonElement
149+
150+ expect ( toggle ) . not . toBeNull ( )
151+
152+ toggle . click ( )
153+ await combobox . updateComplete
154+
155+ const input = combobox . shadowRoot ?. querySelector ( 'input.text-input' ) as HTMLInputElement
156+ expect ( input . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
157+ expect ( getPortalRoot ( ) ?. querySelector ( '[role="listbox"]' ) ) . not . toBeNull ( )
158+ } )
159+
138160 it ( 'supports keyboard selection from the input' , async ( ) => {
139161 const combobox = new Combobox ( )
140162 const changed = jest . fn ( )
Original file line number Diff line number Diff line change @@ -88,6 +88,29 @@ describe('SolidUISelect', () => {
8888 expect ( changed ) . toHaveBeenCalledWith ( { value : 'fr' } )
8989 } )
9090
91+ it ( 'opens the popup when clicking the visible trigger toggle' , async ( ) => {
92+ const select = new Select ( )
93+ select . label = 'Language'
94+ select . options = [
95+ { label : 'English' , value : 'en' } ,
96+ { label : 'French' , value : 'fr' }
97+ ]
98+
99+ document . body . appendChild ( select )
100+ await select . updateComplete
101+
102+ const toggle = select . shadowRoot ?. querySelector ( '.select-trigger-toggle' ) as HTMLSpanElement
103+
104+ expect ( toggle ) . not . toBeNull ( )
105+
106+ toggle . click ( )
107+ await select . updateComplete
108+
109+ const trigger = select . shadowRoot ?. querySelector ( 'button.select-trigger' ) as HTMLButtonElement
110+ expect ( trigger . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
111+ expect ( getPortalRoot ( ) ?. querySelector ( '[role="listbox"]' ) ) . not . toBeNull ( )
112+ } )
113+
91114 it ( 'renders the selected option first in the popup' , async ( ) => {
92115 const select = new Select ( )
93116 select . options = [
Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ export class Select extends LitElement {
145145
146146 .select-trigger {
147147 display: block;
148+ position: relative;
148149 width: 100%;
149150 min-width: 0;
150151 min-height: var(--select-trigger-height, var(--min-touch-target, 44px));
@@ -562,12 +563,12 @@ export class Select extends LitElement {
562563 < span class ="select-trigger-label " part ="trigger-label "
563564 > ${ triggerLabel } </ span
564565 >
566+ < span class ="select-trigger-toggle " part ="trigger-toggle ">
567+ < span class ="select-trigger-icon " part ="trigger-icon " aria-hidden ="true "
568+ > ${ downArrowIcon } </ span
569+ >
570+ </ span >
565571 </ button >
566- < span class ="select-trigger-toggle " part ="trigger-toggle ">
567- < span class ="select-trigger-icon " part ="trigger-icon " aria-hidden ="true "
568- > ${ downArrowIcon } </ span
569- >
570- </ span >
571572 </ div >
572573
573574 < div
You can’t perform that action at this time.
0 commit comments