@@ -116,12 +116,14 @@ const SearchBar = forwardRef(
116116 label : labelProp ,
117117 componentsProps,
118118 disabledClear,
119+ disabledFocus,
119120 className,
120121 defaultValue,
121122 value,
122123 elevation,
123124 disabled,
124125 onChange,
126+ onClear,
125127 onFocus,
126128 onBlur,
127129 ...props
@@ -155,6 +157,7 @@ const SearchBar = forwardRef(
155157
156158 const handleClear = ev => {
157159 onChange ( { ...ev , target : { ...ev . target , value : '' } } )
160+ onClear ( ev )
158161 setCurrentValue ( '' )
159162 }
160163
@@ -175,7 +178,7 @@ const SearchBar = forwardRef(
175178 className = { cx ( className , classes . root , {
176179 [ classes . flat ] : ! elevation ,
177180 [ classes . elevation ] : elevation ,
178- [ classes . focused ] : isFocused ,
181+ [ classes . focused ] : isFocused && ! disabledFocus ,
179182 [ classes . disabled ] : disabled
180183 } ) }
181184 ref = { ref }
@@ -233,9 +236,11 @@ SearchBar.defaultProps = {
233236 size : 'small' ,
234237 type : 'search' ,
235238 disabledClear : false ,
239+ disabledFocus : false ,
236240 defaultValue : '' ,
237241 onChange : ( ) => { } ,
238242 onFocus : ( ) => { } ,
243+ onClear : ( ) => { } ,
239244 onBlur : ( ) => { }
240245}
241246
@@ -253,6 +258,7 @@ SearchBar.propTypes = {
253258 /** Used only with self-controlled component */
254259 defaultValue : PropTypes . string ,
255260 disabledClear : PropTypes . bool ,
261+ disabledFocus : PropTypes . bool ,
256262 elevation : PropTypes . bool ,
257263 placeholder : PropTypes . string ,
258264 label : PropTypes . oneOfType ( [
@@ -263,6 +269,7 @@ SearchBar.propTypes = {
263269 disabled : PropTypes . bool ,
264270 onChange : PropTypes . func ,
265271 onFocus : PropTypes . func ,
272+ onClear : PropTypes . func ,
266273 onBlur : PropTypes . func
267274}
268275
0 commit comments