@@ -305,6 +305,28 @@ describe('selecting items', () => {
305305 comboBox . opened = true ;
306306 expectItems ( [ 'apple' , 'banana' , 'lemon' , 'orange' ] ) ;
307307 } ) ;
308+
309+ it ( 'should not include ghost items in the dropdown after items change' , async ( ) => {
310+ comboBox . opened = true ;
311+ await nextRender ( ) ;
312+
313+ comboBox . selectedItems = [ 'lemon' ] ;
314+ comboBox . items = [ 'apple' , 'banana' , 'lemon' ] ;
315+ await nextRender ( ) ;
316+
317+ expectItems ( [ 'lemon' , 'apple' , 'banana' ] ) ;
318+ } ) ;
319+
320+ it ( 'should not update topgroup when deselecting while dropdown is opened' , async ( ) => {
321+ comboBox . opened = true ;
322+ await nextRender ( ) ;
323+
324+ // Clear selection
325+ comboBox . selectedItems = [ ] ;
326+ await nextRender ( ) ;
327+
328+ expectItems ( [ 'lemon' , 'orange' , 'apple' , 'banana' ] ) ;
329+ } ) ;
308330 } ) ;
309331
310332 describe ( 'object items' , ( ) => {
@@ -388,6 +410,36 @@ describe('selecting items', () => {
388410 comboBox . opened = true ;
389411 expectItems ( [ 'apple' , 'banana' , 'lemon' , 'orange' ] ) ;
390412 } ) ;
413+
414+ it ( 'should not include ghost items in the dropdown after clearing data provider cache' , async ( ) => {
415+ const allItems = [ 'apple' , 'banana' , 'lemon' , 'orange' ] ;
416+ comboBox . dataProvider = ( _params , callback ) => {
417+ callback ( allItems , allItems . length ) ;
418+ } ;
419+
420+ comboBox . opened = true ;
421+ await nextRender ( ) ;
422+
423+ allItems . pop ( ) ; // remove 'orange'
424+ comboBox . selectedItems = [ 'lemon' ] ;
425+ expectItems ( [ 'lemon' , 'orange' , 'apple' , 'banana' ] ) ;
426+
427+ comboBox . clearCache ( ) ;
428+ await nextRender ( ) ;
429+
430+ expectItems ( [ 'lemon' , 'apple' , 'banana' ] ) ;
431+ } ) ;
432+
433+ it ( 'should not include ghost items in the dropdown after data provider change' , async ( ) => {
434+ comboBox . opened = true ;
435+ await nextRender ( ) ;
436+
437+ comboBox . selectedItems = [ 'lemon' ] ;
438+ comboBox . dataProvider = getDataProvider ( [ 'apple' , 'banana' , 'lemon' ] ) ;
439+ await nextRender ( ) ;
440+
441+ expectItems ( [ 'lemon' , 'apple' , 'banana' ] ) ;
442+ } ) ;
391443 } ) ;
392444
393445 describe ( 'lazy loading' , ( ) => {
0 commit comments