fix: display current object name in morph relation picker after rename (#17209)

**Summary**

Issue #16963: When an object is renamed, the morph relation picker still
shows the old name.

**Root cause**

The picker used searchRecord.objectNameSingular from the GraphQL search
response, which can be stale after a rename.
The search record stores the object name at query time, not the current
metadata.

**Solution**

- Updated SingleRecordPickerMenuItem:
- Added useObjectMetadataItems to access current object metadata.
- Look up the current object metadata by morphItem.objectMetadataId.
- Use labelSingular (or nameSingular as fallback) instead of
searchRecord.objectNameSingular for display.
- Updated MultipleRecordPickerMenuItemContent:
- Use objectMetadataItem.labelSingular (already available as a prop)
instead of searchRecord.objectNameSingular.

---------

Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
This commit is contained in:
Ayesha Waseem
2026-01-22 20:40:57 +05:00
committed by GitHub
parent 1e9cd2f5c6
commit 669da1a87d
16 changed files with 146 additions and 35 deletions
@@ -33,15 +33,11 @@ export const MultiSelectControl = ({
}: MultiSelectControlProps) => {
const theme = useTheme();
if (selectedOptions.length === 0) {
return null;
}
const firstSelectedOption = selectedOptions[0];
const firstSelectedOption = selectedOptions?.[0];
return (
<StyledControlContainer
disabled={isDisabled}
hasIcon={isDefined(fixedIcon) || isDefined(firstSelectedOption.Icon)}
hasIcon={isDefined(fixedIcon) || isDefined(firstSelectedOption?.Icon)}
selectSizeVariant={selectSizeVariant}
textAccent={textAccent}
hasRightElement={hasRightElement}
@@ -52,7 +48,7 @@ export const MultiSelectControl = ({
size: theme.icon.size.md,
stroke: theme.icon.stroke.sm,
})
) : isDefined(firstSelectedOption.Icon) ? (
) : isDefined(firstSelectedOption?.Icon) ? (
<firstSelectedOption.Icon
color={isDisabled ? theme.font.color.light : theme.font.color.primary}
size={theme.icon.size.md}
@@ -62,7 +58,7 @@ export const MultiSelectControl = ({
{isDefined(fixedText) ? (
<OverflowingTextWithTooltip text={fixedText} />
) : (
<OverflowingTextWithTooltip text={firstSelectedOption.label} />
<OverflowingTextWithTooltip text={firstSelectedOption?.label ?? ''} />
)}
<StyledSelectControlIconChevronDown