mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Lens] Do not show legend actions popup when in non-interactive mode (#115804)
* 🐛 Fix non-interactive legend issue * ✅ Add tests Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
ee5b847533
commit
1b3f2cdedf
4 changed files with 24 additions and 9 deletions
|
@ -302,12 +302,13 @@ describe('PieVisualization component', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
test('does not set click listener on non-interactive mode', () => {
|
||||
test('does not set click listener and legend actions on non-interactive mode', () => {
|
||||
const defaultArgs = getDefaultArgs();
|
||||
const component = shallow(
|
||||
<PieComponent args={{ ...args }} {...defaultArgs} interactive={false} />
|
||||
);
|
||||
expect(component.find(Settings).first().prop('onElementClick')).toBeUndefined();
|
||||
expect(component.find(Settings).first().prop('legendAction')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('it renders the empty placeholder when metric contains only falsy data', () => {
|
||||
|
|
|
@ -290,7 +290,7 @@ export function PieComponent(
|
|||
legendPosition={legendPosition || Position.Right}
|
||||
legendMaxDepth={nestedLegend ? undefined : 1 /* Color is based only on first layer */}
|
||||
onElementClick={props.interactive ?? true ? onElementClickHandler : undefined}
|
||||
legendAction={getLegendAction(firstTable, onClickValue)}
|
||||
legendAction={props.interactive ? getLegendAction(firstTable, onClickValue) : undefined}
|
||||
theme={{
|
||||
...chartTheme,
|
||||
background: {
|
||||
|
|
|
@ -1485,6 +1485,16 @@ describe('xy_expression', () => {
|
|||
expect(wrapper.find(Settings).first().prop('onElementClick')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('legendAction is not triggering event on non-interactive mode', () => {
|
||||
const { args, data } = sampleArgs();
|
||||
|
||||
const wrapper = mountWithIntl(
|
||||
<XYChart {...defaultProps} data={data} args={args} interactive={false} />
|
||||
);
|
||||
|
||||
expect(wrapper.find(Settings).first().prop('legendAction')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('it renders stacked bar', () => {
|
||||
const { data, args } = sampleArgs();
|
||||
const component = shallow(
|
||||
|
|
|
@ -599,13 +599,17 @@ export function XYChart({
|
|||
xDomain={xDomain}
|
||||
onBrushEnd={interactive ? (brushHandler as BrushEndListener) : undefined}
|
||||
onElementClick={interactive ? clickHandler : undefined}
|
||||
legendAction={getLegendAction(
|
||||
filteredLayers,
|
||||
data.tables,
|
||||
onClickValue,
|
||||
formatFactory,
|
||||
layersAlreadyFormatted
|
||||
)}
|
||||
legendAction={
|
||||
interactive
|
||||
? getLegendAction(
|
||||
filteredLayers,
|
||||
data.tables,
|
||||
onClickValue,
|
||||
formatFactory,
|
||||
layersAlreadyFormatted
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
showLegendExtra={isHistogramViz && valuesInLegend}
|
||||
/>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue