@@ -88,6 +88,7 @@ const FetchTable = props => {
8888 filtersClassName,
8989 smallCells,
9090 tableClassName,
91+ setTab,
9192 } = props
9293
9394 const globalPageSize = useSelector ( selectPageSize )
@@ -96,7 +97,7 @@ const FetchTable = props => {
9697 const dispatch = useDispatch ( )
9798 const defaultTab = tabs . length > 0 ? tabs [ 0 ] . name : undefined
9899 const [ page , setPage ] = useQueryState ( 'page' , 1 , parseInt )
99- const [ tab , setTab ] = useQueryState ( 'tab' , defaultTab )
100+ const [ queryTab , setQueryTab ] = useQueryState ( 'tab' , defaultTab )
100101 const [ order , setOrder ] = useQueryState ( 'order' , defaultOrder )
101102 const [ query , setQuery ] = useQueryState ( 'query' , '' )
102103 const debouncedQuery = useDebounce (
@@ -113,7 +114,13 @@ const FetchTable = props => {
113114 const mayAdd = 'mayAdd' in base ? base . mayAdd : true
114115 const mayLink = 'mayLink' in base ? base . mayLink : true
115116
116- const filters = { query : debouncedQuery , tab, order, page, limit : globalPageSize ?? pageSize }
117+ const filters = {
118+ query : debouncedQuery ,
119+ queryTab,
120+ order,
121+ page,
122+ limit : globalPageSize ?? pageSize ,
123+ }
117124 const [ fetching , setFetching ] = useState ( true )
118125 const [ error , setError ] = useState ( undefined )
119126 let orderDirection , orderBy
@@ -141,10 +148,10 @@ const FetchTable = props => {
141148 const fetchItems = async ( ) => {
142149 setFetching ( true )
143150 const f = { query : debouncedQuery || '' , page, limit : globalPageSize ?? pageSize }
144- if ( tabs . find ( t => t . name === tab ) ) {
145- f . tab = tab
151+ if ( tabs . find ( t => t . name === queryTab ) ) {
152+ f . tab = queryTab
146153 } else {
147- setTab ( defaultTab )
154+ setQueryTab ( defaultTab )
148155 f . tab = undefined
149156 }
150157
@@ -162,6 +169,7 @@ const FetchTable = props => {
162169 await dispatch ( attachPromise ( searchItemsAction ( f ) ) )
163170 } else {
164171 await dispatch ( attachPromise ( getItemsAction ( f ) ) )
172+ setTab ( f . tab )
165173 }
166174 if ( isMounted . current ) {
167175 setFetching ( false )
@@ -187,9 +195,10 @@ const FetchTable = props => {
187195 pageSize ,
188196 searchItemsAction ,
189197 setOrder ,
190- setTab ,
191- tab ,
192198 tabs ,
199+ queryTab ,
200+ setQueryTab ,
201+ setTab ,
193202 ] )
194203
195204 const onPageChange = useCallback (
@@ -217,11 +226,11 @@ const FetchTable = props => {
217226
218227 const onTabChange = useCallback (
219228 tab => {
220- setTab ( tab )
229+ setQueryTab ( tab )
221230 setPage ( 1 )
222231 setQuery ( '' )
223232 } ,
224- [ setPage , setQuery , setTab ] ,
233+ [ setPage , setQuery , setQueryTab ] ,
225234 )
226235
227236 const rowHrefSelector = useCallback (
@@ -262,11 +271,12 @@ const FetchTable = props => {
262271 < div className = { style . filtersLeft } >
263272 { tabs . length > 0 ? (
264273 < Tabs
265- active = { tab }
274+ active = { queryTab }
266275 className = { style . tabs }
267276 tabs = { tabs }
268277 onTabChange = { onTabChange }
269278 toggleStyle
279+ disabled = { fetching }
270280 />
271281 ) : (
272282 tableTitle && (
@@ -286,6 +296,7 @@ const FetchTable = props => {
286296 className = { style . searchBar }
287297 inputWidth = "full"
288298 maxLength = { searchQueryMaxLength }
299+ disabled = { fetching }
289300 />
290301 ) }
291302 { ( Boolean ( actionItems ) || mayAdd ) && (
@@ -378,6 +389,7 @@ FetchTable.propTypes = {
378389 searchPlaceholderMessage : PropTypes . message ,
379390 searchQueryMaxLength : PropTypes . number ,
380391 searchable : PropTypes . bool ,
392+ setTab : PropTypes . func ,
381393 smallCells : PropTypes . bool ,
382394 tableClassName : PropTypes . string ,
383395 tableTitle : PropTypes . message ,
@@ -416,6 +428,7 @@ FetchTable.defaultProps = {
416428 filtersClassName : undefined ,
417429 smallCells : false ,
418430 tableClassName : undefined ,
431+ setTab : ( ) => { } ,
419432}
420433
421434export default FetchTable
0 commit comments