How to configure scroll view to the top of the page when a page is changed?

Answer

Using React SDK, you can configure the search results interface to scroll view to the top of the page when a page is changed.

To implement this, add the following code to your integration code:

import { EVENT_VALUES_UPDATED } from "@sajari/sdk-react";
CODE
values.listen(EVENT_VALUES_UPDATED, (updates) => {
    if (updates["page"] !== undefined) {
        document.body.scrollIntoView({ behavior: 'smooth' });
    }
});
CODE

This will enable the scroll to the op when the page is changed.

Note that scrollIntoView is not compatible with IE, so if a large percentage of users on your website use IE, then you can use the following instead which is supported by IE:

values.listen(EVENT_VALUES_UPDATED, (updates) => {
    if (updates["page"] !== undefined) {
        window.scrollTo(0, 0);
    }
});
CODE