From 07625f282f0309ef071949a4ce029dfee61a184e Mon Sep 17 00:00:00 2001 From: Bishal Shrestha Date: Mon, 14 Jul 2025 17:28:13 +0545 Subject: [PATCH] refactor: render selected values in selected order --- packages/ui/src/FormWidgets/Select/index.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/FormWidgets/Select/index.tsx b/packages/ui/src/FormWidgets/Select/index.tsx index 8edad1fdc..93340a683 100644 --- a/packages/ui/src/FormWidgets/Select/index.tsx +++ b/packages/ui/src/FormWidgets/Select/index.tsx @@ -251,11 +251,16 @@ export const Select = ({ const selectedOptions = useMemo(() => { if (multiple) { - if (!value?.length) return ""; + if (!value?.length) { + return ""; + } - return normalizedOptions - .filter((opt) => value.includes(opt.value as T)) - .map((opt) => opt.label) + return value + .map( + (value_) => + normalizedOptions.find((opt) => opt.value === value_)?.label, + ) + .filter(Boolean) .join(", "); }