1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: update constraint text field

This commit is contained in:
Fredrik Oseberg 2021-08-27 13:43:28 +02:00
parent fd8d82b9bf
commit b22590600e
2 changed files with 15 additions and 3 deletions

View File

@ -2,7 +2,17 @@ import React from 'react';
import PropTypes from 'prop-types';
import { TextField } from '@material-ui/core';
function InputListField({ label, values = [], error, name, updateValues, placeholder = '', onBlur = () => {} }) {
function InputListField({
label,
values = [],
error,
errorText,
name,
updateValues,
placeholder = '',
onBlur = () => {},
FormHelperTextProps,
}) {
const handleChange = evt => {
const values = evt.target.value.split(/,\s?/);
const trimmedValues = values.map(v => v.trim());
@ -23,8 +33,8 @@ function InputListField({ label, values = [], error, name, updateValues, placeho
return (
<TextField
name={name}
error={error !== undefined}
helperText={error}
error={error}
helperText={errorText}
placeholder={placeholder}
value={values ? values.join(', ') : ''}
onKeyDown={handleKeyDown}
@ -34,6 +44,7 @@ function InputListField({ label, values = [], error, name, updateValues, placeho
style={{ width: '100%' }}
variant="outlined"
size="small"
FormHelperTextProps={FormHelperTextProps}
/>
);
}

View File

@ -157,6 +157,7 @@ const StrategyConstraintInputField = ({
<InputListField
name="values"
error={Boolean(error)}
errorText={error}
onBlur={onBlur}
values={constraint.values}
label="Values (v1, v2, v3)"