Fix Relation display (many side) (#14411)
Fixes https://github.com/twentyhq/twenty/issues/14280. Imitated impementation of MultiSelectFieldDisplay.
This commit is contained in:
+30
-1
@@ -8,9 +8,20 @@ import { useFieldFocus } from '@/object-record/record-field/ui/hooks/useFieldFoc
|
||||
import { useRelationFromManyFieldDisplay } from '@/object-record/record-field/ui/meta-types/hooks/useRelationFromManyFieldDisplay';
|
||||
|
||||
import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
|
||||
import styled from '@emotion/styled';
|
||||
import { useContext } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(1)};
|
||||
justify-content: flex-start;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
export const RelationFromManyFieldDisplay = () => {
|
||||
const { fieldValue, fieldDefinition, generateRecordChipData } =
|
||||
useRelationFromManyFieldDisplay();
|
||||
@@ -51,7 +62,7 @@ export const RelationFromManyFieldDisplay = () => {
|
||||
|
||||
const relationFieldName = fieldName === 'noteTargets' ? 'note' : 'task';
|
||||
|
||||
return (
|
||||
return isFocused ? (
|
||||
<ExpandableList isChipCountDisplayed={isFocused}>
|
||||
{fieldValue
|
||||
.map((record) => {
|
||||
@@ -69,6 +80,24 @@ export const RelationFromManyFieldDisplay = () => {
|
||||
})
|
||||
.filter(isDefined)}
|
||||
</ExpandableList>
|
||||
) : (
|
||||
<StyledContainer>
|
||||
{fieldValue
|
||||
.map((record) => {
|
||||
if (!isDefined(record) || !isDefined(record[relationFieldName])) {
|
||||
return undefined;
|
||||
}
|
||||
return (
|
||||
<RecordChip
|
||||
key={record.id}
|
||||
objectNameSingular={objectNameSingular}
|
||||
record={record[relationFieldName]}
|
||||
forceDisableClick={disableChipClick}
|
||||
/>
|
||||
);
|
||||
})
|
||||
.filter(isDefined)}
|
||||
</StyledContainer>
|
||||
);
|
||||
} else if (isRelationFromActivityTargets) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user