This repository was archived by the owner on Nov 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @crowdstrike/glide-core ' : patch
3+ ---
4+
5+ - Single-select Dropdown now clears its input field when its selected option is removed.
6+ - Single-select Dropdown now sets the value of its input field to the label of the selected option on first render.
Original file line number Diff line number Diff line change @@ -792,6 +792,33 @@ it('sets the `value` of its `<input>` to the label of the selected option when n
792792 expect ( input ?. value ) . to . equal ( option ?. label ) ;
793793} ) ;
794794
795+ it ( 'clears the `value` of its `<input>` when single-select and its selected option is removed' , async ( ) => {
796+ const component = await fixture < GlideCoreDropdown > (
797+ html `< glide-core-dropdown label ="Label " filterable >
798+ < glide-core-dropdown-option
799+ label ="One "
800+ selected
801+ > </ glide-core-dropdown-option >
802+
803+ < glide-core-dropdown-option label ="Two "> </ glide-core-dropdown-option >
804+ </ glide-core-dropdown > ` ,
805+ ) ;
806+
807+ component . querySelector ( 'glide-core-dropdown-option' ) ?. remove ( ) ;
808+
809+ // Wait for `#onDefaultSlotChange()`.
810+ await aTimeout ( 0 ) ;
811+
812+ // Now wait for the forced update in `#onDefaultSlotChange()`.
813+ await component . updateComplete ;
814+
815+ const input = component . shadowRoot ?. querySelector < HTMLInputElement > (
816+ '[data-test="input"]' ,
817+ ) ;
818+
819+ expect ( input ?. value ) . to . be . empty . string ;
820+ } ) ;
821+
795822it ( 'clears the `value` of its `<input>` when multiselect and an option is selected' , async ( ) => {
796823 const component = await fixture < GlideCoreDropdown > (
797824 html `< glide-core-dropdown label ="Label " placeholder ="Placeholder " multiple >
Original file line number Diff line number Diff line change @@ -1276,14 +1276,16 @@ export default class GlideCoreDropdown
12761276 if (
12771277 ! this . multiple &&
12781278 this . #inputElementRef. value &&
1279- this . lastSelectedOption ?. value
1279+ this . lastSelectedOption
12801280 ) {
12811281 this . #inputElementRef. value . value = this . lastSelectedOption . label ;
12821282 this . inputValue = this . lastSelectedOption . label ;
12831283
12841284 this . isInputOverflow =
12851285 this . #inputElementRef. value . scrollWidth >
12861286 this . #inputElementRef. value . clientWidth ;
1287+ } else if ( ! this . multiple && this . #inputElementRef. value ) {
1288+ this . #inputElementRef. value . value = '' ;
12871289 }
12881290 }
12891291
You can’t perform that action at this time.
0 commit comments