Files
JosephandGitHub b59fae0429 [fragment-scroll] Stop blurring on navigations (#96113)
Dynamic pages (all pages in dev), blur and select the body as
`activeElement`.

- [x] e2e for https://github.com/vercel/next.js/issues/96050
- [ ] attempt a fix that prevents blur
2026-07-29 19:13:35 -04:00

33 lines
757 B
TypeScript

'use client'
import { useState } from 'react'
import { useRouter } from 'next/navigation'
// Input lives in a PARENT layout so it survives navigations that only change a
// child segment. Typing pushes a child path + search param.
export default function ComboLayout({
children,
}: {
children: React.ReactNode
}) {
const router = useRouter()
const [value, setValue] = useState('')
return (
<>
<input
autoFocus
data-testid="combo-input"
placeholder="Search"
value={value}
onChange={(event) => {
const nextValue = event.target.value
setValue(nextValue)
router.push('/combo/next?q=' + encodeURIComponent(nextValue))
}}
/>
{children}
</>
)
}