diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx index 78456761a3..e8ab985d1c 100644 --- a/src/renderer/components/+catalog/catalog.tsx +++ b/src/renderer/components/+catalog/catalog.tsx @@ -45,7 +45,7 @@ import hotbarStoreInjectable from "../../../common/hotbar-store.injectable"; import type { HotbarStore } from "../../../common/hotbar-store"; interface Dependencies { - catalogPreviousActiveTabStorage: { set: (value: string ) => void }; + catalogPreviousActiveTabStorage: { set: (value: string ) => void; get: () => string }; catalogEntityStore: CatalogEntityStore; getCategoryColumns: (params: GetCategoryColumnsParams) => CategoryColumns; customCategoryViews: IComputedValue>>; @@ -81,6 +81,12 @@ class NonInjectedCatalog extends React.Component { return `${dereferencedGroup}/${dereferencedKind}`; } + const previousTab = this.props.catalogPreviousActiveTabStorage.get(); + + if (previousTab) { + return previousTab; + } + return browseCatalogTab; } @@ -92,8 +98,6 @@ class NonInjectedCatalog extends React.Component { disposeOnUnmount(this, [ this.props.catalogEntityStore.watch(), reaction(() => this.routeActiveTab, async (routeTab) => { - this.props.catalogPreviousActiveTabStorage.set(this.routeActiveTab); - try { await when(() => (routeTab === browseCatalogTab || !!catalogCategoryRegistry.filteredItems.find(i => i.getId() === routeTab)), { timeout: 5_000 }); // we need to wait because extensions might take a while to load const item = catalogCategoryRegistry.filteredItems.find(i => i.getId() === routeTab); @@ -178,9 +182,10 @@ class NonInjectedCatalog extends React.Component { }); if (activeCategory) { - + this.props.catalogPreviousActiveTabStorage.set(`${activeCategory.spec.group}/${activeCategory.spec.names.kind}`); this.props.navigateToCatalog({ group: activeCategory.spec.group, kind: activeCategory.spec.names.kind }); } else { + this.props.catalogPreviousActiveTabStorage.set(null); this.props.navigateToCatalog({ group: browseCatalogTab }); } }); diff --git a/src/renderer/components/hotbar/hotbar-menu.tsx b/src/renderer/components/hotbar/hotbar-menu.tsx index 96d812aeb1..c7550a0744 100644 --- a/src/renderer/components/hotbar/hotbar-menu.tsx +++ b/src/renderer/components/hotbar/hotbar-menu.tsx @@ -75,17 +75,17 @@ class NonInjectedHotbarMenu extends React.Component { const hotbar = this.props.hotbarStore; hotbar.removeFromHotbar(uid); - } + }; - addItem(entity: CatalogEntity, index = -1) { + addItem = (entity: CatalogEntity, index = -1) => { const hotbar = this.props.hotbarStore; hotbar.addToHotbar(entity, index); - } + }; getMoveAwayDirection(entityId: string, cellIndex: number) { const draggableItemIndex = this.hotbar.items.findIndex(item => item?.entity.uid == entityId);