Files
twenty/packages/twenty-front/src/modules/ui/input/components/MultiSelectControl.tsx
T
Marie 54cf857a1a Revert "fix: prevent default object re-selection in relation field fo… (#17619)
I suggest to revert [this
PR](https://github.com/twentyhq/twenty/pull/17313) as it had already
been fixed [in this
PR](https://github.com/twentyhq/twenty/pull/17209/changes) (which fixes
more than it says in its title). Issue was tracked by [this
ticket](https://github.com/twentyhq/core-team-issues/issues/2049) not
very explicit - sorry, my fault.
Code added in the PR does not add value
2026-02-02 10:51:11 +00:00

71 lines
2.0 KiB
TypeScript

import {
type SelectControlProps,
StyledControlContainer,
StyledSelectControlIconChevronDown,
} from '@/ui/input/components/SelectControl';
import { useTheme } from '@emotion/react';
import React from 'react';
import { isDefined } from 'twenty-shared/utils';
import {
type IconComponent,
OverflowingTextWithTooltip,
} from 'twenty-ui/display';
type MultiSelectOptionType = {
label: string;
Icon: IconComponent;
};
type MultiSelectControlProps = Omit<SelectControlProps, 'selectedOption'> & {
fixedIcon?: IconComponent;
fixedText?: string;
selectedOptions: MultiSelectOptionType[];
};
export const MultiSelectControl = ({
fixedIcon,
fixedText,
selectedOptions,
isDisabled,
selectSizeVariant,
textAccent = 'default',
hasRightElement,
}: MultiSelectControlProps) => {
const theme = useTheme();
const firstSelectedOption = selectedOptions?.[0];
return (
<StyledControlContainer
disabled={isDisabled}
hasIcon={isDefined(fixedIcon) || isDefined(firstSelectedOption?.Icon)}
selectSizeVariant={selectSizeVariant}
textAccent={textAccent}
hasRightElement={hasRightElement}
>
{isDefined(fixedIcon) ? (
React.createElement(fixedIcon, {
color: isDisabled ? theme.font.color.light : theme.font.color.primary,
size: theme.icon.size.md,
stroke: theme.icon.stroke.sm,
})
) : isDefined(firstSelectedOption?.Icon) ? (
<firstSelectedOption.Icon
color={isDisabled ? theme.font.color.light : theme.font.color.primary}
size={theme.icon.size.md}
stroke={theme.icon.stroke.sm}
/>
) : null}
{isDefined(fixedText) ? (
<OverflowingTextWithTooltip text={fixedText} />
) : (
<OverflowingTextWithTooltip text={firstSelectedOption?.label ?? ''} />
)}
<StyledSelectControlIconChevronDown
disabled={isDisabled}
size={theme.icon.size.md}
/>
</StyledControlContainer>
);
};