File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
packages/kit-headless/src/components/select Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export type Opt = {
1414*/
1515export const Select : FunctionComponent < SelectProps > = ( props ) => {
1616 const { children : myChildren , ...rest } = props ;
17- let valuePropIndex = 0 ;
17+ let valuePropIndex = null ;
1818 const childrenToProcess = (
1919 Array . isArray ( myChildren ) ? [ ...myChildren ] : [ myChildren ]
2020 ) as Array < JSXNode > ;
@@ -74,7 +74,8 @@ export const Select: FunctionComponent<SelectProps> = (props) => {
7474 }
7575 }
7676 const isDisabledArr = opts . map ( ( opt ) => opt . isDisabled ) ;
77- if ( isDisabledArr [ valuePropIndex ] === true ) {
77+
78+ if ( valuePropIndex !== null && isDisabledArr [ valuePropIndex ] === true ) {
7879 valuePropIndex = isDisabledArr . findIndex ( ( isDisabled ) => isDisabled === false ) ;
7980 if ( valuePropIndex === - 1 ) {
8081 throw new Error (
Original file line number Diff line number Diff line change @@ -10,10 +10,14 @@ export const SelectValue = component$((props: SelectValueProps) => {
1010 const context = useContext ( SelectContextId ) ;
1111 if ( ! context . options ) return ;
1212
13- const selectedOptStr = context . options [ context . selectedIndexSig . value ! ] . value ;
13+ const selectedOptStr =
14+ context . selectedIndexSig . value !== null
15+ ? context . options [ context . selectedIndexSig . value ] . value
16+ : props . placeholder ;
17+
1418 return (
1519 < span data-value { ...props } >
16- { selectedOptStr ?? context . value ?? props . placeholder }
20+ { selectedOptStr }
1721 </ span >
1822 ) ;
1923} ) ;
You can’t perform that action at this time.
0 commit comments