diff --git a/src/core_plugins/metric_vis/public/components/metric_vis_value.js b/src/core_plugins/metric_vis/public/components/metric_vis_value.js index acf05a4bd5d542..c184f2fb582c38 100644 --- a/src/core_plugins/metric_vis/public/components/metric_vis_value.js +++ b/src/core_plugins/metric_vis/public/components/metric_vis_value.js @@ -72,7 +72,7 @@ class MetricVisValue extends Component { ); - if (this.onClick) { + if (hasFilter) { return ({metricComponent}); } diff --git a/src/core_plugins/metric_vis/public/components/metric_vis_value.test.js b/src/core_plugins/metric_vis/public/components/metric_vis_value.test.js new file mode 100644 index 00000000000000..6919a09ba96600 --- /dev/null +++ b/src/core_plugins/metric_vis/public/components/metric_vis_value.test.js @@ -0,0 +1,46 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; +import { shallow } from 'enzyme'; + +import { MetricVisValue } from './metric_vis_value'; + +describe('MetricVisValue', () => { + it('should be wrapped in EuiKeyboardAccessible if having a click listener', () => { + const component = shallow( + {}} + /> + ); + expect(component.find('EuiKeyboardAccessible').exists()).toBe(true); + }); + + it('should not be wrapped in EuiKeyboardAccessible without having a click listener', () => { + const component = shallow( + + ); + expect(component.find('EuiKeyboardAccessible').exists()).toBe(false); + }); + +}); diff --git a/src/core_plugins/metric_vis/public/metric_vis_controller.js b/src/core_plugins/metric_vis/public/metric_vis_controller.js index 3afcace106c74c..dfe5d48f83695f 100644 --- a/src/core_plugins/metric_vis/public/metric_vis_controller.js +++ b/src/core_plugins/metric_vis/public/metric_vis_controller.js @@ -166,7 +166,7 @@ export class MetricVisComponent extends Component { key={index} metric={metric} fontSize={this.props.vis.params.metric.style.fontSize} - onFilter={metric.filterKey ? this._filterBucket : null} + onFilter={metric.filterKey && metric.bucketAgg ? this._filterBucket : null} showLabel={this.props.vis.params.metric.labels.show} /> );