Skip to content

Commit 38eaedc

Browse files
committed
fix(forms): only validate an element if the element exists
1 parent 76d18c9 commit 38eaedc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

demo/DialogExamples.jsx

+10
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ export function DialogExamples() {
107107
console.warn('cancel');
108108
close();
109109
}}
110+
validations={{
111+
test: [
112+
{
113+
message: 'Should be different from test',
114+
validate(value) {
115+
return value !== 'test';
116+
},
117+
},
118+
],
119+
}}
110120
>
111121
<FormGroupInput name="test" label="Test" required />
112122
</Form>

src/forms/helpers/form-helpers.js

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export function validateFormElement({ name, validations = [], formData, elementR
1919
});
2020

2121
for (const elementRef of elementRefs) {
22+
if (!elementRef) {
23+
continue;
24+
}
25+
2226
elementRef.setCustomValidity(validationMessage);
2327
}
2428

0 commit comments

Comments
 (0)