From: Mathieu Suen Date: Mon, 25 Apr 2022 08:41:31 +0000 (+0200) Subject: SONAR-16297 Replace React legacy lifecycle methods in the global Search X-Git-Tag: 9.5.0.56709~217 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e377ee8c0a152016507ca97d42ed52a170d9d7ed;p=sonarqube.git SONAR-16297 Replace React legacy lifecycle methods in the global Search --- diff --git a/server/sonar-web/src/main/js/app/components/search/Search.tsx b/server/sonar-web/src/main/js/app/components/search/Search.tsx index 9d3c30f43ff..4ddad49b88e 100644 --- a/server/sonar-web/src/main/js/app/components/search/Search.tsx +++ b/server/sonar-web/src/main/js/app/components/search/Search.tsx @@ -84,10 +84,6 @@ export class Search extends React.PureComponent { }); } - componentWillUpdate() { - this.nodes = {}; - } - componentDidUpdate(_prevProps: WithRouterProps, prevState: State) { if (prevState.selected !== this.state.selected) { this.scrollToSelected(); @@ -171,6 +167,7 @@ export class Search extends React.PureComponent { if (this.mounted && this.state.query === query) { const results: Results = {}; const more: More = {}; + this.nodes = {}; response.results.forEach(group => { results[group.q] = group.items.map(item => ({ ...item, qualifier: group.q })); more[group.q] = group.more; diff --git a/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx b/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx index 6856767f4c5..a34ee40cfd3 100644 --- a/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx +++ b/server/sonar-web/src/main/js/app/components/search/SearchResult.tsx @@ -53,10 +53,10 @@ export default class SearchResult extends React.PureComponent { } } - componentWillReceiveProps(nextProps: Props) { - if (!this.props.selected && nextProps.selected) { + componentDidUpdate(prevProps: Props) { + if (!prevProps.selected && this.props.selected) { this.scheduleTooltip(); - } else if (this.props.selected && !nextProps.selected) { + } else if (prevProps.selected && !this.props.selected) { this.unscheduleTooltip(); this.setState({ tooltipVisible: false }); }