interface SearchInputDataProps {
value: string;
label?: string;
+ selfClearProp: string;
}
interface SearchInputActionProps {
interface SearchInputState {
value: string;
label: string;
+ selfClearProp: string;
}
export const DEFAULT_SEARCH_DEBOUNCE = 1000;
class extends React.Component<SearchInputProps> {
state: SearchInputState = {
value: "",
- label: ""
+ label: "",
+ selfClearProp: ""
};
timeout: number;
<InputLabel>{this.state.label}</InputLabel>
<Input
type="text"
+ data-cy="search-input"
value={this.state.value}
onChange={this.handleChange}
endAdornment={
if (nextProps.value !== this.props.value) {
this.setState({ value: nextProps.value });
}
+ if (nextProps.selfClearProp !== this.state.selfClearProp) {
+ this.props.onSearch('');
+ this.setState({ selfClearProp: nextProps.selfClearProp });
+ }
}
componentWillUnmount() {