Skip to content

Commit

Permalink
Merge pull request #969 from sap-labs-france/search_input
Browse files Browse the repository at this point in the history
Fixed search bar
  • Loading branch information
AlixH authored Jan 10, 2023
2 parents 1ae8f12 + 09da12d commit 5e55e6d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/search/simple/SimpleSearchComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ export default class SimpleSearchComponent extends React.Component<Props, State>
}

public componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State>, snapshot?: any) {
if (this.props.searchText !== this.state.searchText) {
this.setState({searchText: this.props.searchText}, () => this.props.onChange(this.props.searchText));
const { searchText } = this.props;
// If prop has changed and component is not aware, use prop for search input
if ((searchText !== prevProps.searchText) && (searchText !== this.state.searchText)) {
this.setState({searchText}, () => this.props.onChange(searchText));
}
}

Expand Down

0 comments on commit 5e55e6d

Please sign in to comment.