Skip to content

The open alternative to Salesforce, designed for AI.

Fix placeholders in select (#9608)

Thomas Trompetteb83793f9dc2b
diff --git a/packages/twenty-front/src/modules/object-record/record-field/components/FormFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/components/FormFieldInput.tsx
index 9f04809278f..75fd09a47c9 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/components/FormFieldInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/components/FormFieldInput.tsx
@@ -92,6 +92,7 @@ export const FormFieldInput = ({
options={field.metadata.options}
clearLabel={field.label}
readonly={readonly}
+ placeholder={field.label}
/>
) : isFieldFullName(field) ? (
<FormFullNameFieldInput
@@ -157,6 +158,7 @@ export const FormFieldInput = ({
VariablePicker={VariablePicker}
options={field.metadata.options}
readonly={readonly}
+ placeholder={field.label}
/>
) : isFieldRawJson(field) ? (
<FormRawJsonFieldInput
diff --git a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormCountrySelectInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormCountrySelectInput.tsx
index 3e1dd15d322..bd6673c0203 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormCountrySelectInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormCountrySelectInput.tsx
@@ -59,6 +59,7 @@ export const FormCountrySelectInput = ({
defaultValue={selectedCountryName}
readonly={readonly}
VariablePicker={VariablePicker}
+ placeholder="Select a country"
preventDisplayPadding
/>
);
diff --git a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormCurrencyFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormCurrencyFieldInput.tsx
index 06cc9a2b5dc..c236726119a 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormCurrencyFieldInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormCurrencyFieldInput.tsx
@@ -62,6 +62,7 @@ export const FormCurrencyFieldInput = ({
clearLabel={'Currency Code'}
VariablePicker={VariablePicker}
readonly={readonly}
+ placeholder="Select a currency"
preventDisplayPadding
/>
<FormNumberFieldInput
diff --git a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormMultiSelectFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormMultiSelectFieldInput.tsx
index dbdd873334e..ac9c54c2f96 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormMultiSelectFieldInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormMultiSelectFieldInput.tsx
@@ -14,8 +14,9 @@ import { InputLabel } from '@/ui/input/components/InputLabel';
import { OverlayContainer } from '@/ui/layout/overlay/components/OverlayContainer';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { isStandaloneVariableString } from '@/workflow/utils/isStandaloneVariableString';
+import { useTheme } from '@emotion/react';
import { useId, useState } from 'react';
-import { VisibilityHidden } from 'twenty-ui';
+import { IconChevronDown, VisibilityHidden } from 'twenty-ui';
import { isDefined } from '~/utils/isDefined';
type FormMultiSelectFieldInputProps = {
@@ -25,6 +26,7 @@ type FormMultiSelectFieldInputProps = {
onPersist: (value: FieldMultiSelectValue | string) => void;
VariablePicker?: VariablePickerComponent;
readonly?: boolean;
+ placeholder?: string;
};
const StyledDisplayModeReadonlyContainer = styled.div`
@@ -52,6 +54,12 @@ const StyledSelectInputContainer = styled.div`
top: ${({ theme }) => theme.spacing(8)};
`;
+const StyledPlaceholder = styled.div`
+ color: ${({ theme }) => theme.font.color.light};
+ font-weight: ${({ theme }) => theme.font.weight.medium};
+ width: 100%;
+`;
+
export const FormMultiSelectFieldInput = ({
label,
defaultValue,
@@ -59,8 +67,10 @@ export const FormMultiSelectFieldInput = ({
onPersist,
VariablePicker,
readonly,
+ placeholder,
}: FormMultiSelectFieldInputProps) => {
const inputId = useId();
+ const theme = useTheme();
const hotkeyScope = MULTI_OBJECT_RECORD_SELECT_SELECTABLE_LIST_ID;
@@ -163,6 +173,8 @@ export const FormMultiSelectFieldInput = ({
)
: undefined;
+ const placeholderText = placeholder ?? label;
+
return (
<FormFieldInputContainer>
{label ? <InputLabel>{label}</InputLabel> : null}
@@ -174,12 +186,18 @@ export const FormMultiSelectFieldInput = ({
{draftValue.type === 'static' ? (
readonly ? (
<StyledDisplayModeReadonlyContainer>
- {isDefined(selectedOptions) && (
+ {isDefined(selectedOptions) && selectedOptions.length > 0 ? (
<MultiSelectDisplay
values={selectedNames}
options={selectedOptions}
/>
+ ) : (
+ <StyledPlaceholder />
)}
+ <IconChevronDown
+ size={theme.icon.size.md}
+ color={theme.font.color.light}
+ />
</StyledDisplayModeReadonlyContainer>
) : (
<StyledDisplayModeContainer
@@ -188,12 +206,18 @@ export const FormMultiSelectFieldInput = ({
>
<VisibilityHidden>Edit</VisibilityHidden>
- {isDefined(selectedOptions) && (
+ {isDefined(selectedOptions) && selectedOptions.length > 0 ? (
<MultiSelectDisplay
values={selectedNames}
options={selectedOptions}
/>
+ ) : (
+ <StyledPlaceholder>{placeholderText}</StyledPlaceholder>
)}
+ <IconChevronDown
+ size={theme.icon.size.md}
+ color={theme.font.color.tertiary}
+ />
</StyledDisplayModeContainer>
)
) : (
diff --git a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormSelectFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormSelectFieldInput.tsx
index 37b42aad46a..c302478a865 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormSelectFieldInput.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/form-types/components/FormSelectFieldInput.tsx
@@ -29,6 +29,7 @@ type FormSelectFieldInputProps = {
clearLabel?: string;
readonly?: boolean;
preventDisplayPadding?: boolean;
+ placeholder?: string;
};
const StyledDisplayModeReadonlyContainer = styled.div`
@@ -39,7 +40,6 @@ const StyledDisplayModeReadonlyContainer = styled.div`
font-family: inherit;
padding-inline: ${({ theme }) => theme.spacing(2)};
width: 100%;
- justify-content: space-between;
`;
const StyledDisplayModeContainer = styled(StyledDisplayModeReadonlyContainer)`
@@ -49,7 +49,12 @@ const StyledDisplayModeContainer = styled(StyledDisplayModeReadonlyContainer)`
&[data-open='true'] {
background-color: ${({ theme }) => theme.background.transparent.lighter};
}
- justify-content: space-between;
+`;
+
+const StyledPlaceholder = styled.div`
+ color: ${({ theme }) => theme.font.color.light};
+ font-weight: ${({ theme }) => theme.font.weight.medium};
+ width: 100%;
`;
const StyledSelectInputContainer = styled.div`
@@ -58,6 +63,11 @@ const StyledSelectInputContainer = styled.div`
top: ${({ theme }) => theme.spacing(8)};
`;
+const StyledSelectDisplayContainer = styled.div`
+ display: flex;
+ width: 100%;
+`;
+
export const FormSelectFieldInput = ({
label,
defaultValue,
@@ -67,6 +77,7 @@ export const FormSelectFieldInput = ({
clearLabel,
readonly,
preventDisplayPadding,
+ placeholder,
}: FormSelectFieldInputProps) => {
const inputId = useId();
@@ -215,6 +226,8 @@ export const FormSelectFieldInput = ({
...filteredOptions.map((option) => option.value),
];
+ const placeholderText = placeholder ?? label;
+
return (
<FormFieldInputContainer>
{label ? <InputLabel>{label}</InputLabel> : null}
@@ -226,17 +239,21 @@ export const FormSelectFieldInput = ({
{draftValue.type === 'static' ? (
readonly ? (
<StyledDisplayModeReadonlyContainer>
- {isDefined(selectedOption) && (
- <SelectDisplay
- color={selectedOption.color ?? 'transparent'}
- label={selectedOption.label}
- Icon={selectedOption.icon ?? undefined}
- preventPadding={preventDisplayPadding}
- />
+ {isDefined(selectedOption) ? (
+ <StyledSelectDisplayContainer>
+ <SelectDisplay
+ color={selectedOption.color ?? 'transparent'}
+ label={selectedOption.label}
+ Icon={selectedOption.icon ?? undefined}
+ preventPadding={preventDisplayPadding}
+ />
+ </StyledSelectDisplayContainer>
+ ) : (
+ <StyledPlaceholder />
)}
<IconChevronDown
size={theme.icon.size.md}
- color={theme.font.color.tertiary}
+ color={theme.font.color.light}
/>
</StyledDisplayModeReadonlyContainer>
) : (
@@ -246,13 +263,17 @@ export const FormSelectFieldInput = ({
>
<VisibilityHidden>Edit</VisibilityHidden>
- {isDefined(selectedOption) && (
- <SelectDisplay
- color={selectedOption.color ?? 'transparent'}
- label={selectedOption.label}
- Icon={selectedOption.icon ?? undefined}
- preventPadding={preventDisplayPadding}
- />
+ {isDefined(selectedOption) ? (
+ <StyledSelectDisplayContainer>
+ <SelectDisplay
+ color={selectedOption.color ?? 'transparent'}
+ label={selectedOption.label}
+ Icon={selectedOption.icon ?? undefined}
+ preventPadding={preventDisplayPadding}
+ />
+ </StyledSelectDisplayContainer>
+ ) : (
+ <StyledPlaceholder>{placeholderText}</StyledPlaceholder>
)}
<IconChevronDown
size={theme.icon.size.md}
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowEditActionFormUpdateRecord.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowEditActionFormUpdateRecord.tsx
index eb079c63613..2a915437382 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowEditActionFormUpdateRecord.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowEditActionFormUpdateRecord.tsx
@@ -222,6 +222,7 @@ export const WorkflowEditActionFormUpdateRecord = ({
onPersist={(fieldsToUpdate) =>
handleFieldChange('fieldsToUpdate', fieldsToUpdate)
}
+ placeholder="Select fields to update"
/>
<HorizontalSeparator noMargin />