diff --git a/services/oodikone2-frontend/src/components/PopulationSearchForm/index.jsx b/services/oodikone2-frontend/src/components/PopulationSearchForm/index.jsx index e8c0676ae8..ca0c1e37a1 100644 --- a/services/oodikone2-frontend/src/components/PopulationSearchForm/index.jsx +++ b/services/oodikone2-frontend/src/components/PopulationSearchForm/index.jsx @@ -385,9 +385,17 @@ class PopulationSearchForm extends Component { getMinSelection = (startYear, semester) => (semester === 'FALL' ? `${startYear}-08-01` : `${startYear}-01-01`) + checkPreviousQuery = (query, previousQuery) => { + const sameProgramme = query.studyRights.programme === previousQuery.studyRights.programme + const sameMonths = query.months === previousQuery.months + const sameStartYear = query.startYear === previousQuery.startYear + return sameProgramme && sameMonths && sameStartYear + } + fetchPopulationFromUrlParams() { + const previousQuery = this.props.queries const query = this.parseQueryFromUrl() - if (query.fetch && query !== this.state.query) { + if (query.fetch || !this.checkPreviousQuery(query, previousQuery)) { this.setState({ query }) this.fetchPopulation(query) }