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

fix: CommandPalette doesn't appear from global menu by click/hotkey

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-05-14 14:29:24 +03:00
parent b1ae284b3b
commit 291595d476
2 changed files with 11 additions and 6 deletions

View File

@ -39,7 +39,7 @@ export interface CommandRegistration {
}
export class CommandRegistry extends BaseRegistry<CommandRegistration> {
@observable activeEntity: CatalogEntity;
@observable.ref activeEntity: CatalogEntity;
constructor() {
super();

View File

@ -29,6 +29,7 @@ import { EventEmitter } from "../../../common/event-emitter";
import { subscribeToBroadcast } from "../../../common/ipc";
import { CommandDialog } from "./command-dialog";
import { CommandRegistration, commandRegistry } from "../../../extensions/registries/command-registry";
import type { ClusterId } from "../../../common/cluster-store";
export type CommandDialogEvent = {
component: React.ReactElement
@ -46,11 +47,15 @@ export class CommandOverlay {
}
}
@observer
export class CommandContainer extends React.Component<{ clusterId?: string }> {
@observable.ref commandComponent: React.ReactElement;
export interface CommandContainerProps {
clusterId?: ClusterId;
}
constructor(props: { clusterId?: string }) {
@observer
export class CommandContainer extends React.Component<CommandContainerProps> {
@observable.ref commandComponent: React.ReactNode = null;
constructor(props: CommandContainerProps) {
super(props);
makeObservable(this);
}
@ -88,7 +93,7 @@ export class CommandContainer extends React.Component<{ clusterId?: string }> {
});
} else {
subscribeToBroadcast("command-palette:open", () => {
CommandOverlay.open(<CommandDialog />);
this.commandComponent = <CommandDialog />;
});
}
window.addEventListener("keyup", (e) => this.escHandler(e), true);