@@ -55,7 +55,7 @@ const WithResources = ({ renderChildren }: WithResourcesProps) => {
5555} ;
5656
5757const ResourcesTabTables = ( { renderChildren } : WithResourcesProps ) => {
58- const { resources, resourceFields, selectedResource , handleState, onResourceChange } = useStore ( ) ;
58+ const { resources, resourceFields, selectedTab , handleState, onResourceChange } = useStore ( ) ;
5959
6060 const tabs : ButtonTabProps [ ] = resources . map ( ( res ) => {
6161 return {
@@ -66,7 +66,7 @@ const ResourcesTabTables = ({ renderChildren }: WithResourcesProps) => {
6666 } ) ;
6767
6868 const setTab = ( tab : DefaultResource [ "assignee" ] ) => {
69- handleState ( tab , "selectedResource " ) ;
69+ handleState ( tab , "selectedTab " ) ;
7070 if ( typeof onResourceChange === "function" ) {
7171 const selected = resources . find ( ( re ) => re [ resourceFields . idField ] === tab ) ;
7272 if ( selected ) {
@@ -77,17 +77,18 @@ const ResourcesTabTables = ({ renderChildren }: WithResourcesProps) => {
7777
7878 const currentTabSafeId = useMemo ( ( ) => {
7979 const firstId = resources [ 0 ] [ resourceFields . idField ] ;
80- if ( ! selectedResource ) {
80+ if ( ! selectedTab ) {
8181 return firstId ;
8282 }
83+
8384 // Make sure current selected id is within the resources array
84- const idx = resources . findIndex ( ( re ) => re [ resourceFields . idField ] === selectedResource ) ;
85+ const idx = resources . findIndex ( ( re ) => re [ resourceFields . idField ] === selectedTab ) ;
8586 if ( idx < 0 ) {
8687 return firstId ;
8788 }
8889
89- return selectedResource ;
90- } , [ resources , selectedResource , resourceFields . idField ] ) ;
90+ return selectedTab ;
91+ } , [ resources , resourceFields . idField , selectedTab ] ) ;
9192
9293 return (
9394 < ButtonTabs tabs = { tabs } tab = { currentTabSafeId } setTab = { setTab } style = { { display : "grid" } } />
0 commit comments