Enhanced ObjectSelect component to handle array inputs by normalizing values to a string of IDs, improving identity detection for in-place updates.

This commit is contained in:
Tom Butcher 2025-12-09 02:10:09 +00:00
parent 7f11168b25
commit b7e81e2caa

View File

@ -56,6 +56,26 @@ const ObjectSelect = ({
// Normalize a value to an identity string so we can detect in-place _id updates
const getValueIdentity = useCallback((val) => {
if (val && typeof val === 'object') {
// Handle arrays
if (Array.isArray(val)) {
const ids = val
.map((item) => {
if (item && typeof item === 'object') {
if (item._id) return String(item._id)
if (
item.value &&
typeof item.value === 'object' &&
item.value._id
)
return String(item.value._id)
}
return null
})
.filter(Boolean)
.sort()
return ids.length > 0 ? ids.join(',') : JSON.stringify(val)
}
// Handle single objects
if (val._id) return String(val._id)
if (val.value && typeof val.value === 'object' && val.value._id)
return String(val.value._id)