Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSVB] Shows wrong labels when we get only one series after splitting #111736

Merged
merged 9 commits into from
Sep 13, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@
min-height: $tvbSplitBlockVisMinSize / 1.25;
}
}

// When there is only one visualization, expand the full height and remove all minimum sizes
.tvbSplitVis--one {
flex: 1;

.tvbSplitVis__split {
min-width: 0;

> .tvbVis {
min-height: 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import React, { useCallback } from 'react';
import classNames from 'classnames';
import { getDisplayName } from './lib/get_display_name';
import { labelDateFormatter } from './lib/label_date_formatter';
import { findIndex, first } from 'lodash';
Expand Down Expand Up @@ -40,8 +41,7 @@ export function visWithSplits(WrappedComponent) {
[model, palettesService, syncColors, visData]
);

if (!model || !visData || !visData[model.id] || visData[model.id].series.length === 1)
return <WrappedComponent {...props} />;
if (!model || !visData || !visData[model.id]) return <WrappedComponent {...props} />;
if (visData[model.id].series.every((s) => s.id.split(':').length === 1)) {
return <WrappedComponent {...props} />;
}
Expand Down Expand Up @@ -105,7 +105,10 @@ export function visWithSplits(WrappedComponent) {
},
};
return (
<div key={key} className="tvbSplitVis__split">
<div
key={key}
className="tvbSplitVis__split"
>
<WrappedComponent
model={model}
visData={newVisData}
Expand All @@ -119,7 +122,15 @@ export function visWithSplits(WrappedComponent) {
);
});

return <div className="tvbSplitVis">{rows}</div>;
const hasOneVis = visData[model.id].series.length === 1;

return (
<div
className={classNames('tvbSplitVis', {'tvbSplitVis--one': hasOneVis})}
>
{rows}
</div>
);
}

SplitVisComponent.displayName = `SplitVisComponent(${getDisplayName(WrappedComponent)})`;
Expand Down