Skip to content

Commit 68dbabf

Browse files
refactor: render selected values in selected order (#1520)
1 parent 3d8433a commit 68dbabf

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

packages/ui/src/FormWidgets/Select/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,16 @@ export const Select = <T extends string | number>({
251251

252252
const selectedOptions = useMemo(() => {
253253
if (multiple) {
254-
if (!value?.length) return "";
254+
if (!value?.length) {
255+
return "";
256+
}
255257

256-
return normalizedOptions
257-
.filter((opt) => value.includes(opt.value as T))
258-
.map((opt) => opt.label)
258+
return value
259+
.map(
260+
(value_) =>
261+
normalizedOptions.find((opt) => opt.value === value_)?.label,
262+
)
263+
.filter(Boolean)
259264
.join(", ");
260265
}
261266

0 commit comments

Comments
 (0)