Skip to content

Commit

Permalink
Fixed issue with typing multiple characters for Selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 3, 2022
1 parent 3559e71 commit 48bd6d8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
9 changes: 7 additions & 2 deletions ui/src/app/form/component/widgets/TextWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,23 @@ const TextWidget = ({
rawErrors = [],
...props
}) => {
const _onChange = ({target: { value }}) => onChange(value === "" ? options.emptyValue : value);
const _onChange = ({target: { value }}) => setFieldValue(value === "" ? options.emptyValue : value);
const _onBlur = ({ target: { value } }) => onBlur(id, value);
const _onFocus = ({target: { value }} ) => onFocus(id, value);
const inputType = (type || schema.type) === 'string' ? 'text' : `${type || schema.type}`;

const [touched, setTouched] = React.useState(false);
const [fieldValue, setFieldValue] = React.useState(value || value === 0 ? value : "");

const onCustomBlur = (evt) => {
setTouched(true);
_onBlur(evt);
};

React.useEffect(() => {
onChange(fieldValue);
}, [fieldValue, onChange]);

// const classNames = [rawErrors?.length > 0 ? "is-invalid" : "", type === 'file' ? 'custom-file-label': ""]
return (
<Form.Group>
Expand All @@ -60,7 +65,7 @@ const TextWidget = ({
className={rawErrors?.length > 0 && touched ? "is-invalid" : ""}
list={schema.examples ? `examples_${id}` : undefined}
type={inputType}
value={value || value === 0 ? value : ""}
value={fieldValue}
onChange={_onChange}
onBlur={onCustomBlur}
onFocus={_onFocus}
Expand Down
11 changes: 8 additions & 3 deletions ui/src/app/form/component/widgets/TextareaWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const TextareaWidget = ({
}) => {
const _onChange = ({
target: { value },
}) =>
onChange(value === "" ? options.emptyValue : value);
}) => setFieldValue(value === "" ? options.emptyValue : value);

const _onBlur = ({
target: { value },
}) => onBlur(id, value);
Expand All @@ -38,6 +38,11 @@ const TextareaWidget = ({
}) => onFocus(id, value);

const [touched, setTouched] = React.useState(false);
const [fieldValue, setFieldValue] = React.useState(value || value === 0 ? value : "");

React.useEffect(() => {
onChange(fieldValue);
}, [fieldValue, onChange]);

const onCustomBlur = (evt) => {
setTouched(true);
Expand All @@ -60,7 +65,7 @@ const TextareaWidget = ({
placeholder={placeholder}
disabled={disabled}
readOnly={readonly}
value={value}
value={fieldValue}
required={required}
autoFocus={autofocus}
rows={options.rows || 5}
Expand Down
8 changes: 6 additions & 2 deletions ui/src/app/form/component/widgets/UpDownWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const UpDownWidget = ({
}) => {
const _onChange = ({
target: { value },
}) => onChange(value);
}) => setFieldValue(value);
const _onBlur = ({ target: { value } }) =>
onBlur(id, value);
const _onFocus = ({
Expand All @@ -37,6 +37,10 @@ const UpDownWidget = ({
const translator = useTranslator();

const [touched, setTouched] = React.useState(false);
const [fieldValue, setFieldValue] = React.useState(value);
React.useEffect(() => {
onChange(fieldValue);
}, [fieldValue, onChange]);

const onCustomBlur = (evt) => {
setTouched(true);
Expand All @@ -60,7 +64,7 @@ const UpDownWidget = ({
disabled={disabled}
readOnly={readonly}
placeholder={uiSchema['ui:placeholder'] ? translator(uiSchema['ui:placeholder']) : ''}
value={value || value === 0 ? value : ""}
value={fieldValue}
step={schema.multipleOf}
onChange={_onChange}
onBlur={onCustomBlur}
Expand Down

0 comments on commit 48bd6d8

Please sign in to comment.