Skip to content

Commit 148d80a

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

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

+13-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,15 @@ 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+
if (!popoverOpen) setPopoverOpen(true);
128+
}}
129+
onBlur={() => {
130+
setPopoverOpen(false);
131+
}}
121132
className="rich-input__text"
122133
/>
123134
</InputGroupItem>
@@ -135,6 +146,7 @@ const RichInputField: React.FC<RichInputFieldPropsProps> = React.forwardRef(
135146
richValidationMessages={richValidationMessages as Record<string, string>}
136147
/>
137148
}
149+
withFocusTrap={false}
138150
>
139151
<Button variant="plain" aria-label="Validation">
140152
{!isValid ? (

0 commit comments

Comments
 (0)