Skip to content

Commit

Permalink
fix(app-headless-cms): pass placeholder to select field renderer (#4209)
Browse files Browse the repository at this point in the history
  • Loading branch information
leopuleo authored Jul 30, 2024
1 parent 4525f46 commit b638f0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const plugin: CmsModelFieldRendererPlugin = {
label={field.label}
description={field.helpText}
options={options}
placeholder={field.placeholderText}
data-testid={`fr.input.select.${field.label}`}
/>
</Bind>
Expand Down
5 changes: 4 additions & 1 deletion packages/ui/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ export const Select = (props: SelectProps) => {

// Memoize the label and placeholder values based on the component size.
const { label, placeholder } = useMemo(() => {
const { size, label, placeholder } = props;
const { size, label, placeholder: placeholderText } = props;

// If `placeholderText` is null, undefined, or an empty string after trimming, `placeholder` will be set to `undefined`.
const placeholder = placeholderText?.trim() || undefined;

// For small or medium size, we set only the placeholder, using label as fallback.
if (size === "small" || size === "medium") {
Expand Down

0 comments on commit b638f0d

Please sign in to comment.