Fix new metric popover showing previous popover's title (#12385)
This commit is contained in:
parent
64b49778c5
commit
14ccbe43b3
|
|
@ -26,7 +26,6 @@ const propTypes = {
|
|||
label: PropTypes.string,
|
||||
hasCustomLabel: PropTypes.bool,
|
||||
}),
|
||||
defaultLabel: PropTypes.string,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export type AdhocMetricPopoverTriggerProps = {
|
|||
export type AdhocMetricPopoverTriggerState = {
|
||||
popoverVisible: boolean;
|
||||
title: { label: string; hasCustomLabel: boolean };
|
||||
labelModified: boolean;
|
||||
};
|
||||
|
||||
class AdhocMetricPopoverTrigger extends React.PureComponent<
|
||||
|
|
@ -55,6 +56,7 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
|||
label: props.adhocMetric.label,
|
||||
hasCustomLabel: props.adhocMetric.hasCustomLabel,
|
||||
},
|
||||
labelModified: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -65,6 +67,7 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
|||
label: label || this.props.adhocMetric.label,
|
||||
hasCustomLabel: !!label,
|
||||
},
|
||||
labelModified: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +77,9 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
|||
|
||||
closePopover() {
|
||||
this.togglePopover(false);
|
||||
this.setState({
|
||||
labelModified: false,
|
||||
});
|
||||
}
|
||||
|
||||
togglePopover(visible: boolean) {
|
||||
|
|
@ -84,11 +90,15 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
|||
|
||||
render() {
|
||||
const { adhocMetric } = this.props;
|
||||
const { label, hasCustomLabel } = adhocMetric;
|
||||
const title = this.state.labelModified
|
||||
? this.state.title
|
||||
: { label, hasCustomLabel };
|
||||
|
||||
const overlayContent = (
|
||||
<AdhocMetricEditPopover
|
||||
adhocMetric={adhocMetric}
|
||||
title={this.state.title}
|
||||
title={title}
|
||||
columns={this.props.columns}
|
||||
savedMetrics={this.props.savedMetrics}
|
||||
savedMetric={this.props.savedMetric}
|
||||
|
|
@ -101,8 +111,7 @@ class AdhocMetricPopoverTrigger extends React.PureComponent<
|
|||
|
||||
const popoverTitle = (
|
||||
<AdhocMetricEditPopoverTitle
|
||||
title={this.state.title}
|
||||
defaultLabel={adhocMetric.label}
|
||||
title={title}
|
||||
onChange={this.onLabelChange}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue