NORY-45: fix search input value lost on reload

This commit is contained in:
Markus Thielker 2025-01-04 13:29:19 +01:00
parent 19e68b8929
commit 5e01a7f50f
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View file

@ -29,7 +29,10 @@ export default async function UserPage(
</p>
</div>
<div className="space-y-2">
<SearchInput queryParamKey="query" placeholder="Search for identifiers (Email, Username...)"/>
<SearchInput
value={query}
queryParamKey="query"
placeholder="Search for identifiers (Email, Username...)"/>
<IdentityDataTable
data={initialData}
page={page}

View file

@ -5,13 +5,14 @@ import { useRouter, useSearchParams } from 'next/navigation';
import { ChangeEvent, HTMLInputTypeAttribute } from 'react';
interface SearchInputProps {
value: string;
placeholder: string;
queryParamKey: string;
type?: HTMLInputTypeAttribute;
className?: string;
}
export function SearchInput({ placeholder, queryParamKey, type, className }: SearchInputProps) {
export function SearchInput({ value, placeholder, queryParamKey, type, className }: SearchInputProps) {
const router = useRouter();
const params = useSearchParams();
@ -32,6 +33,7 @@ export function SearchInput({ placeholder, queryParamKey, type, className }: Sea
return (
<Input
value={value}
type={type ?? 'text'}
placeholder={placeholder}
className={className}