Add empty option to select form field (#12898)
## Before New option selected, but not taken into account <img width="744" alt="image" src="https://github.com/user-attachments/assets/880421e2-5582-40f3-809a-ef443517b510" /> ## After <img width="750" alt="image" src="https://github.com/user-attachments/assets/d5114712-a08a-4867-a93c-da5240f81472" />
This commit is contained in:
@ -15,6 +15,7 @@ import { isDefined } from 'twenty-shared/utils';
|
|||||||
import { SelectOption } from 'twenty-ui/input';
|
import { SelectOption } from 'twenty-ui/input';
|
||||||
import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';
|
import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
|
import { IconCircleOff } from 'twenty-ui/display';
|
||||||
|
|
||||||
type FormSelectFieldInputProps = {
|
type FormSelectFieldInputProps = {
|
||||||
label?: string;
|
label?: string;
|
||||||
@ -93,6 +94,12 @@ export const FormSelectFieldInput = ({
|
|||||||
(option) => option.value === draftValue.value,
|
(option) => option.value === draftValue.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const emptyOption = {
|
||||||
|
label: `No ${label}`,
|
||||||
|
value: '',
|
||||||
|
Icon: IconCircleOff,
|
||||||
|
};
|
||||||
|
|
||||||
const handleUnlinkVariable = () => {
|
const handleUnlinkVariable = () => {
|
||||||
setDraftValue({
|
setDraftValue({
|
||||||
type: 'static',
|
type: 'static',
|
||||||
@ -132,6 +139,7 @@ export const FormSelectFieldInput = ({
|
|||||||
options={options}
|
options={options}
|
||||||
value={selectedOption?.value}
|
value={selectedOption?.value}
|
||||||
onChange={onSelect}
|
onChange={onSelect}
|
||||||
|
emptyOption={emptyOption}
|
||||||
fullWidth
|
fullWidth
|
||||||
hasRightElement={isDefined(VariablePicker) && !readonly}
|
hasRightElement={isDefined(VariablePicker) && !readonly}
|
||||||
withSearchInput
|
withSearchInput
|
||||||
|
|||||||
Reference in New Issue
Block a user