diff --git a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx index 736bd64ef8b..0ff0ddc03cf 100644 --- a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx +++ b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx @@ -370,8 +370,7 @@ export class PanelEditorUnconnected extends PureComponent { onClick={() => { showModal(UnlinkModal, { onConfirm: () => { - delete this.props.panel.libraryPanel; - this.props.panel.render(); + this.props.panel.unlinkLibraryPanel(); this.forceUpdate(); }, onDismiss: hideModal, diff --git a/public/app/features/dashboard/state/PanelModel.ts b/public/app/features/dashboard/state/PanelModel.ts index 1a02d2e6198..59294a57330 100644 --- a/public/app/features/dashboard/state/PanelModel.ts +++ b/public/app/features/dashboard/state/PanelModel.ts @@ -672,6 +672,12 @@ export class PanelModel implements DataConfigSource, IPanelModel { } this.libraryPanel = libPanel; } + + unlinkLibraryPanel() { + delete this.libraryPanel; + this.configRev++; + this.render(); + } } function getPluginVersion(plugin: PanelPlugin): string { diff --git a/public/app/features/dashboard/utils/panel.ts b/public/app/features/dashboard/utils/panel.ts index 47da3b000ff..6950dadc9d4 100644 --- a/public/app/features/dashboard/utils/panel.ts +++ b/public/app/features/dashboard/utils/panel.ts @@ -87,10 +87,7 @@ export const unlinkLibraryPanel = (panel: PanelModel) => { new ShowModalReactEvent({ component: UnlinkModal, props: { - onConfirm: () => { - delete panel.libraryPanel; - panel.render(); - }, + onConfirm: () => panel.unlinkLibraryPanel(), isOpen: true, }, })