diff --git a/src/renderer/components/+catalog/catalog.tsx b/src/renderer/components/+catalog/catalog.tsx index 777b4c2e7e..f904fe9d9c 100644 --- a/src/renderer/components/+catalog/catalog.tsx +++ b/src/renderer/components/+catalog/catalog.tsx @@ -40,7 +40,7 @@ import { MainLayout } from "../layout/main-layout"; import { cssNames } from "../../utils"; import { makeCss } from "../../../common/utils/makeCss"; import { CatalogEntityDetails } from "./catalog-entity-details"; -import type { CatalogViewRouteParam } from "../../../common/routes"; +import { catalogURL, CatalogViewRouteParam } from "../../../common/routes"; import { CatalogMenu } from "./catalog-menu"; import { HotbarIcon } from "../hotbar/hotbar-icon"; @@ -83,22 +83,17 @@ export class Catalog extends React.Component { this.catalogEntityStore = new CatalogEntityStore(); disposeOnUnmount(this, [ this.catalogEntityStore.watch(), - when(() => catalogCategoryRegistry.items.length > 0, () => { - const item = catalogCategoryRegistry.items.find(i => i.getId() === this.routeActiveTab); + reaction(() => this.routeActiveTab, async (routeTab) => { + await when(() => catalogCategoryRegistry.items.length > 0); + const item = catalogCategoryRegistry.items.find(i => i.getId() === routeTab); - if (item || this.routeActiveTab === undefined) { - this.activeTab = this.routeActiveTab; + if (item || routeTab === undefined) { + this.activeTab = routeTab; this.catalogEntityStore.activeCategory = item; } else { - Notifications.error(

Unknown category: {this.routeActiveTab}

); + Notifications.error(

Unknown category: {routeTab}

); } - }), - reaction(() => catalogCategoryRegistry.items, (items) => { - if (!this.activeTab && items.length > 0) { - this.activeTab = items[0].getId(); - this.catalogEntityStore.activeCategory = items[0]; - } - }), + }, {fireImmediately: true}), ]); } @@ -135,8 +130,11 @@ export class Catalog extends React.Component { onTabChange = (tabId: string | null) => { const activeCategory = this.categories.find(category => category.getId() === tabId); - this.catalogEntityStore.activeCategory = activeCategory; - this.activeTab = activeCategory?.getId(); + if (activeCategory) { + navigate(catalogURL({ params: {group: activeCategory.spec.group, kind: activeCategory.spec.names.kind }})); + } else { + navigate(catalogURL()); + } }; renderNavigation() {