@@ -45,6 +45,21 @@ export const HComboboxRoot: Component<InternalComboboxProps & HComboboxRootImplP
45
45
const HComboboxItemLabel = UserItemLabel ?? InternalComboboxItemLabel ;
46
46
const HComboboxEmpty = InternalComboboxEmpty ;
47
47
48
+ // recursively extracts the markup (ex: styling characters based on search)
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
+ function getInnerText ( node : any ) : string {
51
+ if ( typeof node === 'string' ) return node ;
52
+ if ( Array . isArray ( node ) ) return node . map ( getInnerText ) . join ( '' ) ;
53
+ if ( node && typeof node === 'object' ) {
54
+ if ( 'props' in node && 'children' in node . props ) {
55
+ return getInnerText ( node . props . children ) ;
56
+ } else if ( 'children' in node ) {
57
+ return getInnerText ( node . children ) ;
58
+ }
59
+ }
60
+ return '' ;
61
+ }
62
+
48
63
// source of truth
49
64
const itemsMap = new Map ( ) ;
50
65
let currItemIndex = 0 ;
@@ -94,7 +109,9 @@ export const HComboboxRoot: Component<InternalComboboxProps & HComboboxRootImplP
94
109
}
95
110
96
111
case HComboboxItemLabel : {
97
- const displayValue = child . props . children as string ;
112
+ const displayValue = getInnerText ( child . props . children ) ;
113
+
114
+ console . log ( displayValue ) ;
98
115
99
116
// distinct value, or the display value is the same as the value
100
117
const value = ( givenItemValue !== null ? givenItemValue : displayValue ) as string ;
@@ -114,15 +131,6 @@ export const HComboboxRoot: Component<InternalComboboxProps & HComboboxRootImplP
114
131
_value = value ;
115
132
}
116
133
117
- const isString = typeof child . props . children === 'string' ;
118
-
119
- if ( ! isString ) {
120
- throw new Error (
121
- `Qwik UI: select item label passed was not a string. It was a ${ typeof child
122
- . props . children } .`,
123
- ) ;
124
- }
125
-
126
134
// increment after processing children
127
135
currItemIndex ++ ;
128
136
0 commit comments