Skip to content

Commit

Permalink
Cluster name show validation message when typing characters
Browse files Browse the repository at this point in the history
  • Loading branch information
ammont82 committed Mar 8, 2024
1 parent 8a0e737 commit fbfb148
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libs/ui-lib/lib/common/components/ui/formik/RichInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ const RichInputField: React.FC<RichInputFieldPropsProps> = React.forwardRef(
validate,
idPostfix,
richValidationMessages,
noDefaultOnChange,
onChange,
...props
},
ref: React.Ref<HTMLInputElement>,
) => {
const [popoverOpen, setPopoverOpen] = React.useState(false);
const [field, { error, value, touched }] = useField<string>({
const [field, { error, value, touched }, { setTouched }] = useField<string>({
name: props.name,
validate,
});
Expand All @@ -118,6 +120,15 @@ const RichInputField: React.FC<RichInputFieldPropsProps> = React.forwardRef(
id={fieldId}
isRequired={isRequired}
aria-describedby={`${fieldId}-helper`}
onChange={(event) => {
!noDefaultOnChange && field.onChange(event);
setTouched(true, false);
onChange && onChange(event);
if (!popoverOpen) setPopoverOpen(true);
}}
onBlur={() => {
setTouched(true, false);
}}
className="rich-input__text"
/>
</InputGroupItem>
Expand All @@ -135,6 +146,7 @@ const RichInputField: React.FC<RichInputFieldPropsProps> = React.forwardRef(
richValidationMessages={richValidationMessages as Record<string, string>}
/>
}
withFocusTrap={false}
>
<Button variant="plain" aria-label="Validation">
{!isValid ? (
Expand Down

0 comments on commit fbfb148

Please sign in to comment.