diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx index c6bef2db73ac9..ffd8924887299 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx @@ -157,9 +157,6 @@ export class EmbeddablePanel extends React.Component { } private async refreshBadges() { - if (!this.mounted) { - return; - } if (this.props.showBadges === false) { return; } @@ -173,6 +170,10 @@ export class EmbeddablePanel extends React.Component { embeddable: this.props.embeddable, })) as BadgeAction[]) ?? []; + if (!this.mounted) { + return; + } + const { disabledActions } = this.props.embeddable.getInput(); if (disabledActions) { badges = badges.filter((badge) => disabledActions.indexOf(badge.id) === -1); @@ -186,9 +187,6 @@ export class EmbeddablePanel extends React.Component { } private async refreshNotifications() { - if (!this.mounted) { - return; - } if (this.props.showNotifications === false) { return; } @@ -202,6 +200,10 @@ export class EmbeddablePanel extends React.Component { embeddable: this.props.embeddable, })) as NotificationAction[]) ?? []; + if (!this.mounted) { + return; + } + const { disabledActions } = this.props.embeddable.getInput(); if (disabledActions) { notifications = notifications.filter((badge) => disabledActions.indexOf(badge.id) === -1); @@ -353,20 +355,28 @@ export class EmbeddablePanel extends React.Component { this.subscription.add( this.props.embeddable.getOutput$().subscribe( (output: EmbeddableOutput) => { - this.setState({ - error: output.error, - loading: output.loading, - }); + if (this.mounted) { + this.setState({ + error: output.error, + loading: output.loading, + }); + } }, (error) => { - this.setState({ error }); + if (this.mounted) { + this.setState({ error }); + } } ) ); const node = this.props.embeddable.render(this.embeddableRoot.current) ?? undefined; if (isPromise(node)) { - node.then((resolved) => this.setState({ node: resolved })); + node.then((resolved) => { + if (this.mounted) { + this.setState({ node: resolved }); + } + }); } else { this.setState({ node }); }