diff --git a/src/plugins/kibana_utils/public/render_complete/render_complete_dispatcher.ts b/src/plugins/kibana_utils/public/render_complete/render_complete_dispatcher.ts index 7d6acf953d69b..8ae5cfbe0ca84 100644 --- a/src/plugins/kibana_utils/public/render_complete/render_complete_dispatcher.ts +++ b/src/plugins/kibana_utils/public/render_complete/render_complete_dispatcher.ts @@ -38,8 +38,10 @@ export class RenderCompleteDispatcher { } public setEl(el?: HTMLElement) { - this.el = el; - this.count = 0; + if (this.el !== el) { + this.el = el; + this.count = 0; + } if (el) this.dispatchInProgress(); } @@ -61,7 +63,8 @@ export class RenderCompleteDispatcher { public dispatchError() { if (!this.el) return; this.count++; - this.el.setAttribute('data-render-complete', 'false'); + this.el.setAttribute('data-render-complete', 'true'); + this.el.setAttribute('data-loading', 'false'); this.el.setAttribute('data-rendering-count', String(this.count)); } diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.tsx index d972d85476a17..5bfc0c7608db0 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable.tsx @@ -522,7 +522,9 @@ export class Embeddable } onContainerStateChanged(containerState: LensEmbeddableInput) { - if (this.handleContainerStateChanged(containerState) || this.errors?.length) this.reload(); + if (this.handleContainerStateChanged(containerState)) { + this.reload(); + } } handleContainerStateChanged(containerState: LensEmbeddableInput): boolean { @@ -705,12 +707,19 @@ export class Embeddable this.domNode.setAttribute('data-shared-item', ''); + const error = this.getError(); + this.updateOutput({ ...this.getOutput(), loading: true, - error: this.getError(), + error, }); - this.renderComplete.dispatchInProgress(); + + if (error) { + this.renderComplete.dispatchError(); + } else { + this.renderComplete.dispatchInProgress(); + } const input = this.getInput();