File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -146,18 +146,24 @@ class Dropdown {
146146 */
147147 public selectOption ( value : string ) {
148148 const optionIndex = this . options . findIndex ( ( option ) => value === option . value ) ;
149- if ( this . multipleAllowed && optionIndex > - 1 && ! this . optionsSelected [ 0 ] && ! this . optionsSelected [ optionIndex ] ) {
149+ if ( optionIndex < 0 && ( this . optionsSelected [ 0 ] || this . optionsSelected [ optionIndex ] ) ) return ;
150+ if ( this . multipleAllowed ) {
150151 // Select the option with the specified value
151152 this . optionsSelected [ optionIndex ] = true ;
152-
153- // A change has occurred, re-render the dropdown options
154- const menuScroll = this . menuElem . scrollTop ;
155- this . render ( ) ;
156- if ( this . dropdownVisible ) {
157- this . menuElem . scroll ( 0 , menuScroll ) ;
153+ } else {
154+ for ( let i = 1 ; i < this . optionsSelected . length ; i ++ ) {
155+ this . optionsSelected [ i ] = false ;
158156 }
159- this . changeCallback ( this . getSelectedOptions ( false ) ) ;
157+ this . optionsSelected [ optionIndex ] = true ;
160158 }
159+ // A change has occurred, re-render the dropdown options
160+ const menuScroll = this . menuElem . scrollTop ;
161+ this . render ( ) ;
162+ if ( this . dropdownVisible ) {
163+ this . menuElem . scroll ( 0 , menuScroll ) ;
164+ }
165+ this . changeCallback ( this . getSelectedOptions ( false ) ) ;
166+
161167 }
162168
163169 /**
You can’t perform that action at this time.
0 commit comments