Skip to content

Commit

Permalink
fix(ui): show required indicator for select fields (#9348)
Browse files Browse the repository at this point in the history
### What?
Select field was not showing required indicator despite being marked
required in config.

### Why?
To give end-user feedback when editting required select fields.

### How?
Replacing hardcoded required prop with required prop passed in from
config.

[See
here.](https://github.com/payloadcms/payload/blob/main/packages/ui/src/fields/Select/Input.tsx#L100)
  • Loading branch information
akhrarovsaid authored Nov 19, 2024
1 parent 077d3e7 commit 2c7ea63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/ui/src/fields/Select/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type SelectInputProps = {
readonly options?: OptionObject[]
readonly path: string
readonly readOnly?: boolean
readonly required?: boolean
readonly showError?: boolean
readonly style?: React.CSSProperties
readonly value?: string | string[]
Expand All @@ -56,6 +57,7 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
options,
path,
readOnly,
required,
showError,
style,
value,
Expand Down Expand Up @@ -97,7 +99,9 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
>
<RenderCustomComponent
CustomComponent={Label}
Fallback={<FieldLabel label={label} localized={localized} path={path} required={false} />}
Fallback={
<FieldLabel label={label} localized={localized} path={path} required={required} />
}
/>
<div className={`${fieldBaseClass}__wrap`}>
<RenderCustomComponent
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/fields/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const SelectFieldComponent: SelectFieldClientComponent = (props) => {
options={options}
path={path}
readOnly={readOnly}
required={required}
showError={showError}
style={styles}
value={value as string | string[]}
Expand Down

0 comments on commit 2c7ea63

Please sign in to comment.