@@ -28,7 +28,7 @@ import * as S from './List.styled';
2828
2929const ACList : React . FC = ( ) => {
3030 const { clusterName } = useAppParams < { clusterName : ClusterName } > ( ) ;
31- const [ searchParams ] = useSearchParams ( ) ;
31+ const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
3232 const [ search , setSearch ] = useState ( searchParams . get ( 'q' ) || '' ) ;
3333 const { data : aclList } = useAcls ( { clusterName, search } ) ;
3434 const { deleteResource } = useDeleteAcl ( clusterName ) ;
@@ -41,10 +41,16 @@ const ACList: React.FC = () => {
4141 } = useBoolean ( ) ;
4242 const [ rowId , setRowId ] = React . useState ( '' ) ;
4343
44- // Set the search params to the url based on the localStorage value
4544 useEffect ( ( ) => {
46- setSearch ( searchParams . get ( 'q' ) || '' ) ;
47- } , [ searchParams ] ) ;
45+ const params = new URLSearchParams ( searchParams ) ;
46+ if ( search ) {
47+ params . set ( 'q' , search ) ;
48+ params . set ( 'page' , '1' ) ; // reset to first page on new search
49+ } else {
50+ params . delete ( 'q' ) ;
51+ }
52+ setSearchParams ( params , { replace : true } ) ;
53+ } , [ search ] ) ;
4854
4955 const handleDeleteClick = ( acl : KafkaAcl | null ) => {
5056 if ( acl ) {
@@ -173,7 +179,11 @@ const ACList: React.FC = () => {
173179 </ ActionButton >
174180 </ PageHeading >
175181 < ControlPanelWrapper hasInput >
176- < Search placeholder = "Search by Principle Name" />
182+ < Search
183+ placeholder = "Search by Principal Name"
184+ value = { search }
185+ onChange = { setSearch }
186+ />
177187 </ ControlPanelWrapper >
178188 < Table
179189 columns = { columns }
0 commit comments