Files
b386f680cc Update handling of autoscrolling on navigation in app (#43845)
- Add support for scrolling to the sides and down when navigating
- Add tests for vertical scrolling
- Add tests for horizontal scrolling
- Add tests for `router.refresh()`
	- should not scroll by itself
	- should not block router.push from scrolling
	- should not scroll when page refreshed using fash refresh
- Scroll to the top of document if that gets page into viewport
	- I didn't want to implement some heuristics on if we can scroll to the top of the page so I just scroll there and check.
	- This implementation may not play well with some nested scrollable containers (but that never worked, just FYI)
	
- Improved typings on `BrowserInterface` a little - backward compatible change.

Co-authored-by: Shu Ding <[email protected]>
2023-01-24 15:41:06 +00:00

40 lines
774 B
TypeScript

'use client'
import Link from 'next/link'
import React, { useEffect } from 'react'
import { useRouter } from 'next/navigation'
export default function Layout({ children }: { children: React.ReactNode }) {
const router = useRouter()
// We export these so that we can access them from tests
useEffect(() => {
// @ts-ignore
window.router = router
// @ts-ignore
window.React = React
}, [router])
return (
<html>
<head></head>
<body
style={{
margin: 0,
}}
>
<div
style={{
position: 'fixed',
top: 0,
left: 0,
}}
>
<Link id="to-vertical-page" href="1" />
</div>
{children}
</body>
</html>
)
}