From 291595d47681f015cff54e075edd8aa4cd4f025c Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 14 May 2021 14:29:24 +0300 Subject: [PATCH] fix: CommandPalette doesn't appear from global menu by click/hotkey Signed-off-by: Roman --- src/extensions/registries/command-registry.ts | 2 +- .../command-palette/command-container.tsx | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/extensions/registries/command-registry.ts b/src/extensions/registries/command-registry.ts index badffb4151..c3894b4008 100644 --- a/src/extensions/registries/command-registry.ts +++ b/src/extensions/registries/command-registry.ts @@ -39,7 +39,7 @@ export interface CommandRegistration { } export class CommandRegistry extends BaseRegistry { - @observable activeEntity: CatalogEntity; + @observable.ref activeEntity: CatalogEntity; constructor() { super(); diff --git a/src/renderer/components/command-palette/command-container.tsx b/src/renderer/components/command-palette/command-container.tsx index 549f31d3d6..441dbb0e95 100644 --- a/src/renderer/components/command-palette/command-container.tsx +++ b/src/renderer/components/command-palette/command-container.tsx @@ -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 { + @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(); + this.commandComponent = ; }); } window.addEventListener("keyup", (e) => this.escHandler(e), true);