mirror of
https://github.com/apache/superset.git
synced 2026-05-11 10:55:43 +00:00
fix: Pasting text issues in MetricsControl and AdhocFilterControl inputs (#11445)
* Fix paste not working in Metrics and Filter inputs * Use noOp instead of empty function * Use default Select component instead of OnPasteSelect * Revert onPaste override
This commit is contained in:
committed by
GitHub
parent
ad98981d9d
commit
128ddfabb6
@@ -21,8 +21,7 @@ import PropTypes from 'prop-types';
|
||||
import { t } from '@superset-ui/core';
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import OnPasteSelect from 'src/components/Select/OnPasteSelect';
|
||||
|
||||
import Select from 'src/components/Select';
|
||||
import ControlHeader from '../ControlHeader';
|
||||
import MetricDefinitionOption from '../MetricDefinitionOption';
|
||||
import MetricDefinitionValue from '../MetricDefinitionValue';
|
||||
@@ -143,6 +142,7 @@ export default class MetricsControl extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.onChange = this.onChange.bind(this);
|
||||
this.onPaste = this.onPaste.bind(this);
|
||||
this.onMetricEdit = this.onMetricEdit.bind(this);
|
||||
this.checkIfAggregateInInput = this.checkIfAggregateInInput.bind(this);
|
||||
this.optionsForSelect = this.optionsForSelect.bind(this);
|
||||
@@ -258,6 +258,14 @@ export default class MetricsControl extends React.PureComponent {
|
||||
this.props.onChange(this.props.multi ? optionValues : optionValues[0]);
|
||||
}
|
||||
|
||||
onPaste(evt) {
|
||||
const clipboard = evt.clipboardData.getData('Text');
|
||||
if (!clipboard) {
|
||||
return;
|
||||
}
|
||||
this.checkIfAggregateInInput(clipboard);
|
||||
}
|
||||
|
||||
checkIfAggregateInInput(input) {
|
||||
const lowercaseInput = input.toLowerCase();
|
||||
const aggregateInInput =
|
||||
@@ -335,7 +343,7 @@ export default class MetricsControl extends React.PureComponent {
|
||||
return (
|
||||
<div className="metrics-select">
|
||||
<ControlHeader {...this.props} />
|
||||
<OnPasteSelect
|
||||
<Select
|
||||
isLoading={this.props.isLoading}
|
||||
isMulti={this.props.multi}
|
||||
name={`select-${this.props.name}`}
|
||||
@@ -344,6 +352,7 @@ export default class MetricsControl extends React.PureComponent {
|
||||
value={this.state.value}
|
||||
labelKey="label"
|
||||
valueKey="optionName"
|
||||
onPaste={this.onPaste}
|
||||
clearable={this.props.clearable}
|
||||
closeOnSelect
|
||||
onChange={this.onChange}
|
||||
|
||||
Reference in New Issue
Block a user