WHERE {t('filters by columns')}
diff --git a/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx b/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx
index da1cde11cca9a..a75406fcf183e 100644
--- a/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx
+++ b/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx
@@ -21,7 +21,7 @@ import PropTypes from 'prop-types';
import { FormGroup } from 'react-bootstrap';
import Tabs from 'src/common/components/Tabs';
import Button from 'src/components/Button';
-import Select from 'src/components/Select';
+import { Select } from 'src/common/components/Select';
import { styled, t } from '@superset-ui/core';
import { ColumnOption } from '@superset-ui/chart-controls';
@@ -70,27 +70,12 @@ export default class AdhocMetricEditPopover extends React.Component {
this.handleAceEditorRef = this.handleAceEditorRef.bind(this);
this.refreshAceEditor = this.refreshAceEditor.bind(this);
- this.popoverRef = React.createRef();
-
this.state = {
adhocMetric: this.props.adhocMetric,
width: startingWidth,
height: startingHeight,
};
- this.selectProps = {
- labelKey: 'label',
- isMulti: false,
- autosize: false,
- clearable: true,
- };
-
- this.menuPortalProps = {
- menuPosition: 'fixed',
- menuPlacement: 'bottom',
- menuPortalTarget: this.popoverRef.current,
- };
-
document.addEventListener('mouseup', this.onMouseUp);
}
@@ -118,7 +103,8 @@ export default class AdhocMetricEditPopover extends React.Component {
this.props.onClose();
}
- onColumnChange(column) {
+ onColumnChange(columnId) {
+ const column = this.props.columns.find(column => column.id === columnId);
this.setState(prevState => ({
adhocMetric: prevState.adhocMetric.duplicateWith({
column,
@@ -213,20 +199,23 @@ export default class AdhocMetricEditPopover extends React.Component {
const columnSelectProps = {
placeholder: t('%s column(s)', columns.length),
- options: columns,
value:
(adhocMetric.column && adhocMetric.column.column_name) ||
adhocMetric.inferSqlExpressionColumn(),
onChange: this.onColumnChange,
- optionRenderer: this.renderColumnOption,
- valueKey: 'column_name',
+ allowClear: true,
+ showSearch: true,
+ filterOption: (input, option) =>
+ option.filterBy.toLowerCase().indexOf(input.toLowerCase()) >= 0,
};
const aggregateSelectProps = {
placeholder: t('%s aggregates(s)', AGGREGATES_OPTIONS.length),
- options: AGGREGATES_OPTIONS,
value: adhocMetric.aggregate || adhocMetric.inferSqlExpressionAggregate(),
onChange: this.onAggregateChange,
+ allowClear: true,
+ autoFocus: true,
+ showSearch: true,
};
if (this.props.datasourceType === 'druid') {
@@ -241,7 +230,6 @@ export default class AdhocMetricEditPopover extends React.Component {
column
-
+
aggregate
-
+