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

View File

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