| 50 | // the document is short for a moment. The reader's place is put back once |
| 51 | // the new page has grown to it, instead of leaving them above the rows. |
| 52 | const holdScroll = ( |
| 53 | router: NextRouter, |
| 54 | position: number, |
| 55 | href: string, |
| 56 | ): void => { |
| 57 | let letGo = () => undefined; |
| 58 | const restore = (url: string) => { |
| 59 | letGo(); |
| 60 | if (url.split(/[?#]/)[0] === href) { |
| 61 | restoreScrollPosition(position); |
| 62 | } |
| 63 | }; |
| 64 | letGo = () => { |
| 65 | router.events.off('routeChangeComplete', restore); |
| 66 | router.events.off('routeChangeError', letGo); |
| 67 | }; |
| 68 | router.events.on('routeChangeComplete', restore); |
| 69 | router.events.on('routeChangeError', letGo); |
| 70 | }; |
| 71 | |
| 72 | export function ExploreSortMenu(): ReactElement { |
| 73 | const router = useRouter(); |