Skip to content

Commit ad5011d

Browse files
committed
Change minimization
1 parent 4978306 commit ad5011d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

components/dash-core-components/src/fragments/Dropdown.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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]);

0 commit comments

Comments
 (0)