[TSVB] should call renderComplete once for multi-values visualizations (#143638)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
This commit is contained in:
Alexey Antonov 2022-10-20 16:50:55 +03:00 committed by GitHub
parent 6907156d31
commit b1a88f5c61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 6 deletions

View file

@ -8,9 +8,9 @@
import { useLayoutEffect, ReactNode } from 'react';
interface RenderCounterProps {
initialRender: Function;
postponeExecution?: boolean;
children?: ReactNode;
initialRender: Function | undefined;
}
/** HOC component to call "initialRender" method after finishing all DOM mutations. **/
@ -21,7 +21,7 @@ export const RenderCounter = ({
}: RenderCounterProps) => {
useLayoutEffect(() => {
if (!postponeExecution) {
initialRender();
initialRender?.();
}
}, [initialRender, postponeExecution]);

View file

@ -69,5 +69,5 @@ export interface TimeseriesVisProps {
indexPattern?: FetchedIndexPattern['indexPattern'];
/** @deprecated please use indexPattern.fieldFormatMap instead **/
fieldFormatMap?: FieldFormatMap;
initialRender: () => void;
initialRender: () => void | undefined;
}

View file

@ -89,7 +89,7 @@ export function visWithSplits(WrappedComponent) {
? findIndex(model.series, (s) => s.id === nonSplitSeries.id)
: null;
const rows = Object.keys(splitsVisData).map((key) => {
const rows = Object.keys(splitsVisData).map((key, index, arrayRef) => {
const splitData = splitsVisData[key];
const { series, label } = splitData;
const additionalLabel = label;
@ -115,7 +115,7 @@ export function visWithSplits(WrappedComponent) {
backgroundColor={props.backgroundColor}
getConfig={props.getConfig}
fieldFormatMap={props.fieldFormatMap}
initialRender={props.initialRender}
initialRender={arrayRef.length - 1 === index ? props.initialRender : undefined}
/>
</div>
);

View file

@ -101,7 +101,7 @@ export const TimeSeries = ({
const onRenderChange = useCallback(
(isRendered) => {
if (isRendered) {
initialRender();
initialRender?.();
}
},
[initialRender]