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

[Lens] Do not show legend actions popup when in non-interactive mode #115804

Merged
merged 3 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/lens/public/xy_visualization/expression.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 11 additions & 7 deletions x-pack/plugins/lens/public/xy_visualization/expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>

Expand Down