@@ -34,11 +34,11 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
34
34
return super . value ;
35
35
}
36
36
set value ( newValue ) {
37
+ super . value = newValue ;
38
+
37
39
if ( typeof newValue === 'string' ) {
38
- this . #updateValue( newValue ) ;
40
+ this . #updateValue( ) ;
39
41
}
40
-
41
- super . value = newValue ;
42
42
}
43
43
44
44
/**
@@ -166,7 +166,17 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
166
166
this . #phoneMediaQuery. removeEventListener ( 'change' , this . #onPhoneChange) ;
167
167
}
168
168
169
- protected async firstUpdated ( ) {
169
+ #onSlotChange( ) {
170
+ if ( this . #comboboxList) {
171
+ this . #comboboxList. removeEventListener (
172
+ UUIComboboxListEvent . CHANGE ,
173
+ this . #onChange,
174
+ ) ;
175
+ this . #comboboxList. removeEventListener (
176
+ UUIComboboxListEvent . INNER_SLOT_CHANGE ,
177
+ this . #onInnerSlotChange,
178
+ ) ;
179
+ }
170
180
const list = this . _comboboxListElements ?. [ 0 ] ;
171
181
172
182
if ( list ) {
@@ -178,21 +188,22 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
178
188
) ;
179
189
this . #comboboxList. addEventListener (
180
190
UUIComboboxListEvent . INNER_SLOT_CHANGE ,
181
- this . #onSlotChange ,
191
+ this . #onInnerSlotChange ,
182
192
) ;
183
-
184
- await this . updateComplete ;
185
- this . #updateValue( this . value ) ;
186
193
}
194
+
195
+ this . updateComplete . then ( ( ) => {
196
+ this . #updateValue( ) ;
197
+ } ) ;
187
198
}
188
199
189
200
#onPhoneChange = ( ) => {
190
201
this . _isPhone = this . #phoneMediaQuery. matches ;
191
202
} ;
192
203
193
- #updateValue( value : FormDataEntryValue | FormData ) {
204
+ #updateValue( ) {
194
205
if ( this . #comboboxList) {
195
- this . #comboboxList. value = value ;
206
+ this . #comboboxList. value = this . value ;
196
207
requestAnimationFrame (
197
208
( ) => ( this . _displayValue = this . #comboboxList. displayValue || '' ) ,
198
209
) ;
@@ -233,9 +244,9 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
233
244
this . #onOpen( ) ;
234
245
} ;
235
246
236
- #onSlotChange = ( ) => {
247
+ #onInnerSlotChange = ( ) => {
237
248
if ( this . value && this . value !== this . #comboboxList?. value ) {
238
- this . #updateValue( this . value ) ;
249
+ this . #updateValue( ) ;
239
250
}
240
251
} ;
241
252
@@ -344,7 +355,7 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
344
355
#renderDropdown = ( ) => {
345
356
return html `<div id= "dropdown" >
346
357
<uui- scroll- container tabindex= "-1" id = "scroll-container" >
347
- <slot> </ slot>
358
+ <slot @slotchange = ${ this . #onSlotChange } > </ slot>
348
359
</ uui- scroll- container>
349
360
</ div> ` ;
350
361
} ;
0 commit comments