@@ -28,7 +28,7 @@ import * as S from './List.styled';
28
28
29
29
const ACList : React . FC = ( ) => {
30
30
const { clusterName } = useAppParams < { clusterName : ClusterName } > ( ) ;
31
- const [ searchParams ] = useSearchParams ( ) ;
31
+ const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
32
32
const [ search , setSearch ] = useState ( searchParams . get ( 'q' ) || '' ) ;
33
33
const { data : aclList } = useAcls ( { clusterName, search } ) ;
34
34
const { deleteResource } = useDeleteAcl ( clusterName ) ;
@@ -41,10 +41,16 @@ const ACList: React.FC = () => {
41
41
} = useBoolean ( ) ;
42
42
const [ rowId , setRowId ] = React . useState ( '' ) ;
43
43
44
- // Set the search params to the url based on the localStorage value
45
44
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 ] ) ;
48
54
49
55
const handleDeleteClick = ( acl : KafkaAcl | null ) => {
50
56
if ( acl ) {
@@ -173,7 +179,11 @@ const ACList: React.FC = () => {
173
179
</ ActionButton >
174
180
</ PageHeading >
175
181
< ControlPanelWrapper hasInput >
176
- < Search placeholder = "Search by Principle Name" />
182
+ < Search
183
+ placeholder = "Search by Principal Name"
184
+ value = { search }
185
+ onChange = { setSearch }
186
+ />
177
187
</ ControlPanelWrapper >
178
188
< Table
179
189
columns = { columns }
0 commit comments