fix: fields for opens at and expires at on new form marked as mandatory#813
fix: fields for opens at and expires at on new form marked as mandatory#813priscila-moneo wants to merge 1 commit intomasterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds touched-on-blur handling to MuiFormikDatepicker, marks two sponsor form date fields as required (visual), and introduces unit tests verifying required marker and validation error on blur. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
martinquiroga-exo
left a comment
There was a problem hiding this comment.
@priscila-moneo please see comments. Thanks.
| const [field, meta, helpers] = useField(name); | ||
| const requiredLabel = `${label} *`; | ||
| const handleBlur = () => { | ||
| helpers.setTouched(true); |
There was a problem hiding this comment.
This relies on implicit Formik behavior. It should explicitly trigger validation.:
helpers.setTouched(true, true);
| value={field.value} | ||
| onChange={helpers.setValue} | ||
| onClose={handleBlur} | ||
| slotProps={{ |
There was a problem hiding this comment.
NIT: Since this is out of the scope of this PR I will just call it out:
If a caller passes slotProps through ...props, it will override this entire object, breaking the wrapper.
@caseylocker @smarcet For you consideration.
| renderWithFormik({ required: true }); | ||
|
|
||
| const user = userEvent.setup(); | ||
| const input = screen.getByLabelText("Test Date *"); |
There was a problem hiding this comment.
You only asserts the error appears. It does not prove the blur caused it.
expect(screen.queryByText("This field is required")).not.toBeInTheDocument();
Before the interaction to be explicit.
| const user = userEvent.setup(); | ||
| const input = screen.getByLabelText("Test Date *"); | ||
| await user.click(input); | ||
| input.blur(); |
There was a problem hiding this comment.
Mixes user-event with imperative DOM manipulation and bypasses normal event sequencing.
await user.tab();
This ensures blur happens through the testing-library interaction model.
50b0e5c to
8be526a
Compare
ref: https://app.clickup.com/t/86b84u74z
Summary by CodeRabbit