Skip to content

Commit

Permalink
Merge branch 'main' into fixA11yVideoBlockIssue
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffersonBledsoe authored Jul 25, 2024
2 parents 0b5d814 + ce7a139 commit fb23db0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/volto/news/5464.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed pagination in search results by passing `pageSize` explicitly to all search API calls. @EshaanAgg
18 changes: 13 additions & 5 deletions packages/volto/src/components/theme/Search/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Search extends Component {

constructor(props) {
super(props);
this.defaultPageSize = config.settings.defaultPageSize;
this.state = { currentPage: 1, isClient: false, active: 'relevance' };
}

Expand Down Expand Up @@ -109,19 +110,24 @@ class Search extends Component {
const options = qs.parse(this.props.history.location.search);
this.setState({ currentPage: 1 });
options['use_site_search_settings'] = 1;
this.props.searchContent('', options);
this.props.searchContent('', {
b_size: this.defaultPageSize,
...options,
});
};

handleQueryPaginationChange = (e, { activePage }) => {
const { settings } = config;
window.scrollTo(0, 0);
let options = qs.parse(this.props.history.location.search);
options['use_site_search_settings'] = 1;

this.setState({ currentPage: activePage }, () => {
this.props.searchContent('', {
b_size: this.defaultPageSize,
...options,
b_start: (this.state.currentPage - 1) * settings.defaultPageSize,
b_start:
(this.state.currentPage - 1) *
(options.b_size || this.defaultPageSize),
});
});
};
Expand Down Expand Up @@ -149,7 +155,8 @@ class Search extends Component {
* @returns {string} Markup for the component.
*/
render() {
const { settings } = config;
const options = qs.parse(this.props.history.location.search);

return (
<Container id="page-search">
<Helmet title={this.props.intl.formatMessage(messages.Search)} />
Expand Down Expand Up @@ -282,7 +289,8 @@ class Search extends Component {
<Pagination
activePage={this.state.currentPage}
totalPages={Math.ceil(
this.props.search.items_total / settings.defaultPageSize,
this.props.search.items_total /
(options.b_size || this.defaultPageSize),
)}
onPageChange={this.handleQueryPaginationChange}
firstItem={null}
Expand Down

0 comments on commit fb23db0

Please sign in to comment.