@@ -35,7 +35,7 @@ export interface SearchInputBarProps extends TextInputProps {
3535 /** 点击清除图标时触发事件 */
3636 onClear ?: Function ;
3737 /** 自定义搜索 */
38- searchRender ?: JSX . Element ;
38+ searchRender ?: React . ReactNode ;
3939 /** 输入框TextInput样式 */
4040 inputStyle ?: TextStyle ;
4141 /** loading加载 */
@@ -49,6 +49,7 @@ interface SearchInputBarState {
4949
5050export default class SearchInputBar extends React . Component < SearchInputBarProps , SearchInputBarState > {
5151 public inputRef = React . createRef < TextInput > ( ) ;
52+
5253 constructor ( props : SearchInputBarProps ) {
5354 super ( props ) ;
5455 this . state = {
@@ -59,7 +60,7 @@ export default class SearchInputBar extends React.Component<SearchInputBarProps,
5960 needFocus = ( type : 'search' | 'close' | 'actived' ) => {
6061 if ( type === 'close' ) {
6162 this . props . onClear ?.( ) ;
62- } else if ( type === 'search' && this . props . value ) {
63+ } else if ( type === 'search' ) {
6364 this . props . onSearch ?.( ) ;
6465 return ;
6566 }
@@ -71,7 +72,7 @@ export default class SearchInputBar extends React.Component<SearchInputBarProps,
7172
7273 // 右侧搜索
7374 renderSearch = ( ) => {
74- const { showActionButton, searchRender, touchProps, actionName = '搜索' , loading } = this . props ;
75+ const { showActionButton, searchRender, touchProps, actionName = '搜索' } = this . props ;
7576 const { showIcon } = this . state ;
7677 if ( showActionButton || showIcon ) {
7778 return searchRender ? (
@@ -94,14 +95,15 @@ export default class SearchInputBar extends React.Component<SearchInputBarProps,
9495 containerStyle,
9596 searchIcon,
9697 closeIcon,
97- loading,
98+ loading = false ,
9899 ...other
99100 } = this . props ;
101+
100102 return (
101- < Loader loading = { loading ? loading : false } rounded = { 5 } maskColor = "transparent" >
103+ < Loader loading = { loading } rounded = { 5 } maskColor = "transparent" >
102104 < View style = { [ styles . centerFlex ] } >
103105 < View style = { StyleSheet . flatten ( [ styles . searchContainer , styles . centerFlex , containerStyle ] ) } >
104- < TouchableOpacity style = { { } } onPress = { ( ) => this . needFocus ( 'search' ) } >
106+ < TouchableOpacity onPress = { ( ) => this . needFocus ( 'search' ) } >
105107 < Icon name = "search" size = { 14 } color = { colors . colorsPalette . grey40 } height = { '100%' } { ...searchIcon } />
106108 </ TouchableOpacity >
107109 < TextInput
@@ -117,7 +119,7 @@ export default class SearchInputBar extends React.Component<SearchInputBarProps,
117119 other ?. onFocus ?.( e ) ;
118120 } }
119121 onBlur = { ( e : NativeSyntheticEvent < TextInputFocusEventData > ) => {
120- if ( showActionButton !== null && ! value ) {
122+ if ( showActionButton !== null && ! value && ! loading ) {
121123 this . setState ( { showIcon : false } ) ;
122124 }
123125 other ?. onBlur ?.( e ) ;
0 commit comments