Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pagination): scroll to top on page change #111

Merged
merged 1 commit into from
May 7, 2020

Conversation

francoischalifour
Copy link
Member

Description

This scrolls to top on each page change, which avoids users to scroll back to top manually to scan items.

Changes

I got rid of the ScrollTo component which didn't behave properly, and implemented our own Pagination component.

const { view, ConnectedHit } = useAppContext();
const { view, ConnectedHit, topAnchor } = useAppContext();

const onPageClick = React.useCallback(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to memoize functions passed to React InstantSearch components (Pagination here) otherwise it triggers an infinite loop.

);
});

function getPaddingLeft(currentPage, padding, maxPages, size) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The below methods are taken from the orignal implementation.

@francoischalifour francoischalifour merged commit 71f2c8c into next May 7, 2020
@francoischalifour francoischalifour deleted the feat/pagination-scroll-top branch May 7, 2020 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants