Skip to content

Commit 5dff9b9

Browse files
committed
Cluster name show validation message when typing characters
1 parent 8a0e737 commit 5dff9b9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Diff for: libs/ui-lib/lib/common/components/ui/formik/RichInputField.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ const RichInputField: React.FC<RichInputFieldPropsProps> = React.forwardRef(
8787
validate,
8888
idPostfix,
8989
richValidationMessages,
90+
noDefaultOnChange,
91+
onChange,
9092
...props
9193
},
9294
ref: React.Ref<HTMLInputElement>,
9395
) => {
9496
const [popoverOpen, setPopoverOpen] = React.useState(false);
95-
const [field, { error, value, touched }] = useField<string>({
97+
const [field, { error, value, touched }, { setTouched }] = useField<string>({
9698
name: props.name,
9799
validate,
98100
});
@@ -118,6 +120,18 @@ const RichInputField: React.FC<RichInputFieldPropsProps> = React.forwardRef(
118120
id={fieldId}
119121
isRequired={isRequired}
120122
aria-describedby={`${fieldId}-helper`}
123+
onChange={(event) => {
124+
!noDefaultOnChange && field.onChange(event);
125+
setTouched(true, false);
126+
onChange && onChange(event);
127+
// eslint-disable-next-line no-console
128+
console.log(popoverOpen);
129+
if (!popoverOpen) setPopoverOpen(true);
130+
}}
131+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
132+
setTouched(true, false);
133+
event.target.focus();
134+
}}
121135
className="rich-input__text"
122136
/>
123137
</InputGroupItem>

0 commit comments

Comments
 (0)