File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { cx } from "./tools/cx";
1919import type { FrClassName } from "./fr/generatedFromCss/classNames" ;
2020import { createComponentI18nApi } from "./i18n" ;
2121import { useAnalyticsId } from "./tools/useAnalyticsId" ;
22+ import { exclude } from "tsafe/exclude" ;
2223
2324export type SelectProps < Options extends SelectProps . Option [ ] > = {
2425 id ?: string ;
@@ -154,18 +155,23 @@ function NonMemoizedNonForwardedSelect<T extends SelectProps.Option[]>(
154155 disabled = { disabled }
155156 >
156157 { [
157- {
158- "label" : placeholder === undefined ? t ( "select an option" ) : placeholder ,
159- "selected" : true ,
160- "value" : "" ,
161- "disabled" : true
162- } ,
158+ options . find ( option => option . value === "" ) !== undefined
159+ ? undefined
160+ : {
161+ "label" :
162+ placeholder === undefined ? t ( "select an option" ) : placeholder ,
163+ "selected" : true ,
164+ "value" : "" ,
165+ "disabled" : true
166+ } ,
163167 ...options
164- ] . map ( ( option , index ) => (
165- < option { ...( option as any ) } key = { `${ option . value } -${ index } ` } >
166- { option . label }
167- </ option >
168- ) ) }
168+ ]
169+ . filter ( exclude ( undefined ) )
170+ . map ( ( option , index ) => (
171+ < option { ...( option as any ) } key = { `${ option . value } -${ index } ` } >
172+ { option . label }
173+ </ option >
174+ ) ) }
169175 </ select >
170176 { state !== "default" && (
171177 < p id = { stateDescriptionId } className = { fr . cx ( `fr-${ state } -text` ) } >
You can’t perform that action at this time.
0 commit comments