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:
parent
1b4e105047
commit
c041266b31
@ -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
|
||||||
|
|||||||
@ -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) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user