Skip to content

Commit 2c7ea63

Browse files
authored
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)
1 parent 077d3e7 commit 2c7ea63

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/ui/src/fields/Select/Input.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type SelectInputProps = {
3333
readonly options?: OptionObject[]
3434
readonly path: string
3535
readonly readOnly?: boolean
36+
readonly required?: boolean
3637
readonly showError?: boolean
3738
readonly style?: React.CSSProperties
3839
readonly value?: string | string[]
@@ -56,6 +57,7 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
5657
options,
5758
path,
5859
readOnly,
60+
required,
5961
showError,
6062
style,
6163
value,
@@ -97,7 +99,9 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
9799
>
98100
<RenderCustomComponent
99101
CustomComponent={Label}
100-
Fallback={<FieldLabel label={label} localized={localized} path={path} required={false} />}
102+
Fallback={
103+
<FieldLabel label={label} localized={localized} path={path} required={required} />
104+
}
101105
/>
102106
<div className={`${fieldBaseClass}__wrap`}>
103107
<RenderCustomComponent

packages/ui/src/fields/Select/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const SelectFieldComponent: SelectFieldClientComponent = (props) => {
117117
options={options}
118118
path={path}
119119
readOnly={readOnly}
120+
required={required}
120121
showError={showError}
121122
style={styles}
122123
value={value as string | string[]}

0 commit comments

Comments
 (0)