Skip to content

The open alternative to Salesforce, designed for AI.

Show a placeholder instead of No country, No currency or No calling code in empty form pickers (#28130)

Thomas Trompettee9dd7ca4f267
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCallingCodeSelectInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCallingCodeSelectInput.tsx
index 38a1358a005..700176d6042 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCallingCodeSelectInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCallingCodeSelectInput.tsx
@@ -86,6 +86,7 @@ export const FormCallingCodeSelectInput = ({
onChange={handleChange}
options={options}
defaultValue={defaultValue}
+ placeholder={t`Select a calling code`}
readonly={readonly}
VariablePicker={VariablePicker}
/>
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCountrySelectInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCountrySelectInput.tsx
index 22170e84276..e5bd38378fc 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCountrySelectInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCountrySelectInput.tsx
@@ -59,6 +59,7 @@ export const FormCountrySelectInput = ({
onChange={onCountryChange}
options={options}
defaultValue={selectedCountryName}
+ placeholder={t`Select a country`}
readonly={readonly}
VariablePicker={VariablePicker}
/>
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCurrencyFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCurrencyFieldInput.tsx
index 1c5d0cae004..b98c75119fc 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCurrencyFieldInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCurrencyFieldInput.tsx
@@ -75,6 +75,7 @@ export const FormCurrencyFieldInput = ({
defaultValue={defaultValue?.currencyCode ?? ''}
onChange={handleCurrencyCodeChange}
options={currencies}
+ placeholder={t`Select a currency`}
VariablePicker={VariablePicker}
readonly={readonly}
/>
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormSelectFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormSelectFieldInput.tsx
index 5ff2426a626..98c0ebb74ef 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormSelectFieldInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormSelectFieldInput.tsx
@@ -28,6 +28,7 @@ type FormSelectFieldInputProps = {
readonly?: boolean;
isNullable?: boolean;
callToActionButton?: SelectCallToActionButton;
+ placeholder?: string;
};
export const FormSelectFieldInput = ({
@@ -40,6 +41,7 @@ export const FormSelectFieldInput = ({
readonly,
isNullable,
callToActionButton,
+ placeholder,
}: FormSelectFieldInputProps) => {
const theme = useTheme();
const instanceId = useId();
@@ -104,9 +106,14 @@ export const FormSelectFieldInput = ({
const optionsWithEmptyOption =
isNullable || options.length === 0 ? [emptyOption, ...options] : options;
- const selectedOption = optionsWithEmptyOption.find(
- (option) => option.value === draftValue.value,
- );
+ const isEmptyValueShownAsPlaceholder =
+ isDefined(placeholder) && draftValue.value === '';
+
+ const selectedOption = isEmptyValueShownAsPlaceholder
+ ? undefined
+ : optionsWithEmptyOption.find(
+ (option) => option.value === draftValue.value,
+ );
const handleUnlinkVariable = () => {
setDraftValue({
@@ -144,6 +151,11 @@ export const FormSelectFieldInput = ({
dropdownId={`${instanceId}-select-display`}
options={optionsWithEmptyOption}
value={selectedOption?.value}
+ emptyOption={
+ isDefined(placeholder)
+ ? { label: placeholder, value: '' }
+ : undefined
+ }
onChange={onSelect}
callToActionButton={callToActionButton}
fullWidth
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/__stories__/FormPhoneFieldInput.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/__stories__/FormPhoneFieldInput.stories.tsx
index ab0a37e07dd..31e345ef8ad 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/__stories__/FormPhoneFieldInput.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/__stories__/FormPhoneFieldInput.stories.tsx
@@ -116,7 +116,9 @@ export const SelectingVariables: Story = {
play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);
- const callingCodeDefaultValue = await canvas.findByText('No calling code');
+ const callingCodeDefaultValue = await canvas.findByText(
+ 'Select a calling code',
+ );
expect(callingCodeDefaultValue).toBeVisible();
@@ -150,7 +152,7 @@ export const Disabled: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const callingCodeInput = await canvas.findByText('No calling code');
+ const callingCodeInput = await canvas.findByText('Select a calling code');
expect(callingCodeInput).toBeVisible();
await userEvent.click(callingCodeInput);
diff --git a/packages/twenty-front/src/modules/object-record/record-form/components/__tests__/RecordFormFieldInputs.clearing.test.tsx b/packages/twenty-front/src/modules/object-record/record-form/components/__tests__/RecordFormFieldInputs.clearing.test.tsx
index fb4513a592f..29d4fe32417 100644
--- a/packages/twenty-front/src/modules/object-record/record-form/components/__tests__/RecordFormFieldInputs.clearing.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-form/components/__tests__/RecordFormFieldInputs.clearing.test.tsx
@@ -118,7 +118,7 @@ describe('RecordFormFieldInputs with the real currency input', () => {
expect(onFieldValueClear).not.toHaveBeenCalled();
expect(screen.queryByText(/\(USD\)/)).not.toBeInTheDocument();
- expect(screen.getByText('No currency')).toBeInTheDocument();
+ expect(screen.getByText('Select a currency')).toBeInTheDocument();
});
it('keeps the currency cleared when an amount is typed after clearing', async () => {
diff --git a/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx b/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx
index 68edee392a3..252b2a8f83c 100644
--- a/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx
@@ -58,9 +58,13 @@ export const StyledControlContainer = styled.div<{
? themeCssVariables.font.color.tertiary
: textAccent === 'default'
? themeCssVariables.font.color.primary
- : themeCssVariables.font.color.tertiary};
+ : themeCssVariables.font.color.light};
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
display: grid;
+ font-weight: ${({ textAccent }) =>
+ textAccent === 'placeholder'
+ ? themeCssVariables.font.weight.medium
+ : 'inherit'};
gap: ${themeCssVariables.spacing[1]};
grid-template-columns: ${({ hasIcon }) =>