fix(ui): show required indicator for select fields (#9348)

### 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)
This commit is contained in:
Said Akhrarov
2024-11-19 12:55:26 -05:00
committed by GitHub
parent 077d3e7d16
commit 2c7ea6362a
2 changed files with 6 additions and 1 deletions

View File

@@ -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[]
@@ -56,6 +57,7 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
options,
path,
readOnly,
required,
showError,
style,
value,
@@ -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

View File

@@ -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[]}