File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
components/dash-core-components/src/fragments Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -217,19 +217,20 @@ const Dropdown = (props: DropdownProps) => {
217217 let sortedOptions = filteredOptions ;
218218 if ( multi ) {
219219 // Sort filtered options: selected first, then unselected
220- // ES2019+ guarantees stable sort, preserving order within groups
221220 sortedOptions = [ ...filteredOptions ] . sort ( ( a , b ) => {
222221 const aSelected = sanitizedValues . includes ( a . value ) ;
223222 const bSelected = sanitizedValues . includes ( b . value ) ;
223+
224224 if ( aSelected && ! bSelected ) {
225225 return - 1 ;
226226 }
227227 if ( ! aSelected && bSelected ) {
228228 return 1 ;
229229 }
230- return 0 ;
230+ return 0 ; // Maintain original order within each group
231231 } ) ;
232232 }
233+
233234 setDisplayOptions ( sortedOptions ) ;
234235 }
235236 } , [ filteredOptions , isOpen ] ) ;
You can’t perform that action at this time.
0 commit comments