mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
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
33 lines
757 B
TypeScript
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}
|
|
</>
|
|
)
|
|
}
|