Fix error message not cleared after choosing a color in a color picker (#5794)

This commit is contained in:
AlexandreS
2023-10-18 12:47:57 +02:00
committed by GitHub
parent ffc6f5786b
commit 79cad1da3a
2 changed files with 11 additions and 5 deletions

View File

@@ -23,13 +23,13 @@ export default React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
<GenericExpressionField
expressionType="string"
ref={field}
renderExtraButton={({ style }) => (
renderExtraButton={({ style, onChange }) => (
<ColorPicker
style={style}
disableAlpha
color={rgbStringAndAlphaToRGBColor(props.value)}
onChangeComplete={color => {
props.onChange(
onChange(
'"' + color.rgb.r + ';' + color.rgb.g + ';' + color.rgb.b + '"'
);
}}

View File

@@ -115,6 +115,7 @@ type Props = {|
) => ?string,
renderExtraButton?: ({|
style: Object,
onChange: (newValue: string) => void,
|}) => React.Node,
...ParameterFieldProps,
|};
@@ -232,8 +233,7 @@ export default class ExpressionField extends React.Component<Props, State> {
);
};
_handleBlur = (event: { currentTarget: { value: string } }) => {
const value = event.currentTarget.value;
_handleBlur = (value: string) => {
if (this.props.onChange) this.props.onChange(value);
this.setState({ validatedValue: value }, () => {
this._enqueueValidation.cancel();
@@ -244,6 +244,10 @@ export default class ExpressionField extends React.Component<Props, State> {
});
};
_handleBlurEvent = (event: { currentTarget: { value: string } }) => {
this._handleBlur(event.currentTarget.value);
};
_shouldOpenParametersDialog = (
expressionInfo: EnumeratedExpressionMetadata
): boolean => {
@@ -492,6 +496,7 @@ export default class ExpressionField extends React.Component<Props, State> {
},
completionDescriptions
);
const allNewAutocompletions = onGetAdditionalAutocompletions
? onGetAdditionalAutocompletions(expression).concat(newAutocompletions)
: newAutocompletions;
@@ -571,7 +576,7 @@ export default class ExpressionField extends React.Component<Props, State> {
hintText={expressionType === 'string' ? '""' : undefined}
inputStyle={styles.input}
onChange={this._handleChange}
onBlur={this._handleBlur}
onBlur={this._handleBlurEvent}
ref={field => (this._field = field)}
onFocus={this._handleFocus}
errorText={this.state.errorText}
@@ -677,6 +682,7 @@ export default class ExpressionField extends React.Component<Props, State> {
this.props.renderExtraButton &&
this.props.renderExtraButton({
style,
onChange: this._handleBlur,
})}
{!this.props.isInline && (
<RaisedButton