@@ -79,6 +79,7 @@ import { ImageDropdown } from './addons/ImageDropdown';
7979import { innerText } from '../shared/innerText' ;
8080import TextWithTooltip from './addons/TextWithTooltip' ;
8181import { Thumbnail , CameraIcon } from './addons/CameraIcon' ;
82+ import { FallbackRender } from './addons/FallbackRender' ;
8283
8384const md = new Remarkable ( ) ;
8485
@@ -202,6 +203,7 @@ const SearchBox = (props) => {
202203 // Document suggestions don't have a meaningful label and value
203204 const newSuggestion = { ...suggestion } ;
204205 newSuggestion . label = 'For document suggestions, please implement a renderItem method to display label.' ;
206+ // If renderItem is provided we can get the value from it's content
205207 if ( typeof props . renderItem === 'function' ) {
206208 const jsxEl = props . renderItem ( newSuggestion ) ;
207209 const innerValue = innerText ( jsxEl ) ;
@@ -2039,11 +2041,13 @@ const SearchBox = (props) => {
20392041 ) } `
20402042 } `}
20412043 >
2042- { props . renderItem ? (
2043- props . renderItem (
2044- sectionItem ,
2045- )
2046- ) : (
2044+ < FallbackRender
2045+ item = { typeof props . renderItem === 'function' ? (
2046+ props . renderItem (
2047+ sectionItem ,
2048+ )
2049+ ) : null }
2050+ >
20472051 < React . Fragment >
20482052 < div
20492053 style = { {
@@ -2100,7 +2104,7 @@ const SearchBox = (props) => {
21002104 sectionItem ,
21012105 ) }
21022106 </ React . Fragment >
2103- ) }
2107+ </ FallbackRender >
21042108 </ li >
21052109 ) ,
21062110 ) }
@@ -2136,9 +2140,13 @@ const SearchBox = (props) => {
21362140 ) } `
21372141 } `}
21382142 >
2139- { props . renderItem ? (
2140- props . renderItem ( item )
2141- ) : (
2143+ < FallbackRender
2144+ item = { typeof props . renderItem === 'function' ? (
2145+ props . renderItem (
2146+ item ,
2147+ )
2148+ ) : null }
2149+ >
21422150 < React . Fragment >
21432151 < SuggestionItem
21442152 currentValue = {
@@ -2148,7 +2156,7 @@ const SearchBox = (props) => {
21482156 suggestion = { item }
21492157 />
21502158 </ React . Fragment >
2151- ) }
2159+ </ FallbackRender >
21522160 </ li >
21532161 ) ;
21542162 }
@@ -2172,9 +2180,13 @@ const SearchBox = (props) => {
21722180 ) } `
21732181 } `}
21742182 >
2175- { props . renderItem ? (
2176- props . renderItem ( item )
2177- ) : (
2183+ < FallbackRender
2184+ item = { typeof props . renderItem === 'function' ? (
2185+ props . renderItem (
2186+ item ,
2187+ )
2188+ ) : null }
2189+ >
21782190 < React . Fragment >
21792191 { /* eslint-disable */ }
21802192
@@ -2213,7 +2225,7 @@ const SearchBox = (props) => {
22132225
22142226 { getActionIcon ( item ) }
22152227 </ React . Fragment >
2216- ) }
2228+ </ FallbackRender >
22172229 </ li >
22182230 ) ;
22192231 } ) }
0 commit comments