cdslibrary 1.2.40 → 1.2.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/CDSSelect.jsx +11 -3
- package/package.json +1 -1
package/components/CDSSelect.jsx
CHANGED
|
@@ -76,10 +76,18 @@ export const CDSSelect = ({ label, options = [], onSelect, selectedValue = null
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
const handleSelect = (item) => {
|
|
80
|
+
// 1. Actualizamos localmente PRIMERO para que el cambio sea instantáneo
|
|
80
81
|
setSelectedItem(item);
|
|
82
|
+
|
|
83
|
+
// 2. Cerramos el menú
|
|
81
84
|
toggleDropdown();
|
|
82
|
-
|
|
85
|
+
|
|
86
|
+
// 3. Notificamos al padre
|
|
87
|
+
if (onSelect) {
|
|
88
|
+
// Enviamos el valor (o el objeto, según prefieras)
|
|
89
|
+
onSelect(item.value);
|
|
90
|
+
}
|
|
83
91
|
};
|
|
84
92
|
|
|
85
93
|
return (
|
|
@@ -124,7 +132,7 @@ export const CDSSelect = ({ label, options = [], onSelect, selectedValue = null
|
|
|
124
132
|
renderItem={({ item }) => (
|
|
125
133
|
<SelectOption
|
|
126
134
|
item={item}
|
|
127
|
-
isSelected={
|
|
135
|
+
isSelected={selectedItem?.value === item.value}
|
|
128
136
|
onSelect={handleSelect}
|
|
129
137
|
theme={theme}
|
|
130
138
|
/>
|