Skip to content

Commit

Permalink
UIEH-1442: Do not run clearPackageTitles when loading package titles.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro-Melnyshyn committed Jan 20, 2025
1 parent 2a690fb commit d475cb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
11 changes: 0 additions & 11 deletions src/routes/package-show-route/package-show-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import ReactRouterPropTypes from 'react-router-prop-types';
import queryString from 'qs';
import isEqual from 'lodash/isEqual';
import reduce from 'lodash/reduce';

import { TitleManager } from '@folio/stripes/core';

Expand All @@ -25,7 +24,6 @@ class PackageShowRoute extends Component {
static propTypes = {
accessStatusTypes: accessTypesReduxStateShape.isRequired,
clearCostPerUseData: PropTypes.func.isRequired,
clearPackageTitles: PropTypes.func.isRequired,
costPerUse: costPerUseShape.CostPerUseReduxStateShape.isRequired,
destroyPackage: PropTypes.func.isRequired,
getAccessTypes: PropTypes.func.isRequired,
Expand Down Expand Up @@ -282,17 +280,8 @@ class PackageShowRoute extends Component {
const {
location,
history,
clearPackageTitles,
} = this.props;

const paramDifference = reduce(pkgSearchParams, (result, item, key) => {
return isEqual(item, this.state.pkgSearchParams[key]) ? result : result.concat(key);
}, []);

if (!(paramDifference.length === 1 && paramDifference[0] === 'page')) {
clearPackageTitles();
}

const qs = queryString.parse(location.search, { ignoreQueryPrefix: true });
const search = queryString.stringify({
...qs,
Expand Down
6 changes: 3 additions & 3 deletions src/routes/package-show-route/package-show-route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ describe('Given PackageShowRoute', () => {
});
});

describe('when changed param is not single and it is not "page"', () => {
it('should handle clearPackageTitles', async () => {
describe('when packages are being fetched', () => {
it('should not clear old ones', async () => {
const {
getByRole,
} = renderPackageShowRoute({
Expand All @@ -586,7 +586,7 @@ describe('Given PackageShowRoute', () => {

await userEvent.type(searchBox, 'Title name{enter}');

expect(mockClearPackageTitles).toHaveBeenCalled();
expect(mockClearPackageTitles).not.toHaveBeenCalled();
});
});
});
Expand Down

0 comments on commit d475cb5

Please sign in to comment.