@@ -4,7 +4,7 @@ import type {Category} from '@prisma/client';
44import { MDXRemote , MDXRemoteSerializeResult } from 'next-mdx-remote' ;
55import Link from 'next/link' ;
66import { parseAsArrayOf , parseAsInteger , parseAsString , useQueryState } from 'nuqs' ;
7- import { Fragment } from 'react' ;
7+ import { Fragment , useState } from 'react' ;
88import { Article } from './article' ;
99import { Pagination } from './pagination' ;
1010import { CategoryTag } from './tag' ;
@@ -35,7 +35,8 @@ function changelogEntryPublishDateToAddressableTag(date: Date) {
3535}
3636
3737export function ChangelogList ( { changelogs} : { changelogs : ChangelogEntry [ ] } ) {
38- const [ searchValue , setSearchValue ] = useQueryState ( 'search' , parseAsString ) ;
38+ const [ searchValue , setSearchValue ] = useState < string | null > ( '' ) ;
39+ const [ , setQuerySearchValue ] = useQueryState ( 'search' , parseAsString ) ;
3940
4041 const [ monthAndYearParam , setMonthParam ] = useQueryState ( 'month' ) ;
4142 const [ selectedCategoriesIds , setSelectedCategoriesIds ] = useQueryState (
@@ -207,7 +208,9 @@ export function ChangelogList({changelogs}: {changelogs: ChangelogEntry[]}) {
207208 value = { searchValue ?? '' }
208209 onChange = { e => {
209210 setPageParam ( null ) ;
210- setSearchValue ( e . target . value ? e . target . value : null ) ;
211+ const newSearchValue = e . target . value ? e . target . value : null ;
212+ setSearchValue ( newSearchValue ) ;
213+ setQuerySearchValue ( newSearchValue ) ;
211214 } }
212215 placeholder = "Search..."
213216 className = "form-input flex-1 rounded-md border border-gray-300 bg-white px-4 py-2 text-gray-900 focus:border-primary-500 focus:ring-primary-500"
@@ -217,6 +220,7 @@ export function ChangelogList({changelogs}: {changelogs: ChangelogEntry[]}) {
217220 className = { `${ someFilterIsActive ? 'text-purple font-medium cursor-pointer' : 'text-gray-500 cursor-not-allowed' } hover:text-gray-700` }
218221 onClick = { ( ) => {
219222 setSearchValue ( null ) ;
223+ setQuerySearchValue ( null ) ;
220224 setSelectedCategoriesIds ( null ) ;
221225 setMonthParam ( null ) ;
222226 setPageParam ( null ) ;
0 commit comments