Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions react/SearchBar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ const SearchBar = forwardRef(
label: labelProp,
componentsProps,
disabledClear,
disabledFocus,
className,
defaultValue,
value,
elevation,
disabled,
onChange,
onClear,
onFocus,
onBlur,
...props
Expand Down Expand Up @@ -155,6 +157,7 @@ const SearchBar = forwardRef(

const handleClear = ev => {
onChange({ ...ev, target: { ...ev.target, value: '' } })
onClear(ev)
setCurrentValue('')
}

Expand All @@ -175,7 +178,7 @@ const SearchBar = forwardRef(
className={cx(className, classes.root, {
[classes.flat]: !elevation,
[classes.elevation]: elevation,
[classes.focused]: isFocused,
[classes.focused]: isFocused && !disabledFocus,
[classes.disabled]: disabled
})}
ref={ref}
Expand Down Expand Up @@ -233,9 +236,11 @@ SearchBar.defaultProps = {
size: 'small',
type: 'search',
disabledClear: false,
disabledFocus: false,
defaultValue: '',
onChange: () => {},
onFocus: () => {},
onClear: () => {},
onBlur: () => {}
}

Expand All @@ -253,6 +258,7 @@ SearchBar.propTypes = {
/** Used only with self-controlled component */
defaultValue: PropTypes.string,
disabledClear: PropTypes.bool,
disabledFocus: PropTypes.bool,
elevation: PropTypes.bool,
placeholder: PropTypes.string,
label: PropTypes.oneOfType([
Expand All @@ -263,13 +269,14 @@ SearchBar.propTypes = {
disabled: PropTypes.bool,
onChange: PropTypes.func,
onFocus: PropTypes.func,
onClear: PropTypes.func,
onBlur: PropTypes.func
}

const SearchBarWithLocales = props => {
const SearchBarWithLocales = forwardRef((props, ref) => {
useExtendI18n(locales)

return <SearchBar {...props} />
}
return <SearchBar {...props} ref={ref} />
})

export default SearchBarWithLocales
Loading