1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Set controlled selected prop

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-06-16 10:57:16 +03:00
parent 1b4e105047
commit c041266b31
2 changed files with 3 additions and 2 deletions

View File

@ -31,6 +31,7 @@ import { cssNames } from "../../utils";
import type { CatalogCategory } from "../../api/catalog-entity"; import type { CatalogCategory } from "../../api/catalog-entity";
type Props = { type Props = {
activeItem: string;
onItemClick: (id: string) => void; onItemClick: (id: string) => void;
}; };
@ -61,7 +62,7 @@ export function CatalogMenu(props: Props) {
defaultExpanded={["catalog"]} defaultExpanded={["catalog"]}
defaultCollapseIcon={<Icon material="expand_more"/>} defaultCollapseIcon={<Icon material="expand_more"/>}
defaultExpandIcon={<Icon material="chevron_right" />} defaultExpandIcon={<Icon material="chevron_right" />}
defaultSelected="browse" selected={props.activeItem || "browse"}
> >
<Item nodeId="browse" label="Browse" data-testid="*-tab" onClick={() => props.onItemClick("*")}/> <Item nodeId="browse" label="Browse" data-testid="*-tab" onClick={() => props.onItemClick("*")}/>
<Item <Item

View File

@ -141,7 +141,7 @@ export class Catalog extends React.Component<Props> {
}; };
renderNavigation() { renderNavigation() {
return <CatalogMenu onItemClick={this.onTabChange}/>; return <CatalogMenu activeItem={this.activeTab} onItemClick={this.onTabChange}/>;
} }
renderItemMenu = (item: CatalogEntityItem) => { renderItemMenu = (item: CatalogEntityItem) => {