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:
@@ -33,6 +33,7 @@ export type SelectInputProps = {
|
|||||||
readonly options?: OptionObject[]
|
readonly options?: OptionObject[]
|
||||||
readonly path: string
|
readonly path: string
|
||||||
readonly readOnly?: boolean
|
readonly readOnly?: boolean
|
||||||
|
readonly required?: boolean
|
||||||
readonly showError?: boolean
|
readonly showError?: boolean
|
||||||
readonly style?: React.CSSProperties
|
readonly style?: React.CSSProperties
|
||||||
readonly value?: string | string[]
|
readonly value?: string | string[]
|
||||||
@@ -56,6 +57,7 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
|
|||||||
options,
|
options,
|
||||||
path,
|
path,
|
||||||
readOnly,
|
readOnly,
|
||||||
|
required,
|
||||||
showError,
|
showError,
|
||||||
style,
|
style,
|
||||||
value,
|
value,
|
||||||
@@ -97,7 +99,9 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
|
|||||||
>
|
>
|
||||||
<RenderCustomComponent
|
<RenderCustomComponent
|
||||||
CustomComponent={Label}
|
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`}>
|
<div className={`${fieldBaseClass}__wrap`}>
|
||||||
<RenderCustomComponent
|
<RenderCustomComponent
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ const SelectFieldComponent: SelectFieldClientComponent = (props) => {
|
|||||||
options={options}
|
options={options}
|
||||||
path={path}
|
path={path}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
|
required={required}
|
||||||
showError={showError}
|
showError={showError}
|
||||||
style={styles}
|
style={styles}
|
||||||
value={value as string | string[]}
|
value={value as string | string[]}
|
||||||
|
|||||||
Reference in New Issue
Block a user