From 2d54b6e53675eb98d1d6cebb3342883a8dab90c2 Mon Sep 17 00:00:00 2001 From: Joe Agster Date: Wed, 17 Sep 2025 12:37:18 -0700 Subject: [PATCH 1/2] Remove handling of blue event to prevent persistent error display --- .../apps/search/patient/PatientCriteria/BasicInformation.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/modernization-ui/src/apps/search/patient/PatientCriteria/BasicInformation.tsx b/apps/modernization-ui/src/apps/search/patient/PatientCriteria/BasicInformation.tsx index cec5b67ea3..f9970d8bce 100644 --- a/apps/modernization-ui/src/apps/search/patient/PatientCriteria/BasicInformation.tsx +++ b/apps/modernization-ui/src/apps/search/patient/PatientCriteria/BasicInformation.tsx @@ -117,7 +117,7 @@ export const BasicInformation = ({ sizing, orientation }: EntryFieldsProps) => { rules={{ required: { value: true, message: 'At least one status is required' } }} - render={({ field: { onChange, onBlur, value, name }, fieldState: { error } }) => ( + render={({ field: { onChange, value, name }, fieldState: { error } }) => ( { options={statusOptions} value={value} onChange={onChange} - onBlur={onBlur} error={error?.message} /> )} From 8bbc845bf514a8c15db9127eecf134e8dff5cc68 Mon Sep 17 00:00:00 2001 From: Joe Agster Date: Thu, 18 Sep 2025 09:46:43 -0700 Subject: [PATCH 2/2] Unit test for status checkbox blur behavior --- .../PatientCriteria/BasicInformation.spec.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/modernization-ui/src/apps/search/patient/PatientCriteria/BasicInformation.spec.tsx b/apps/modernization-ui/src/apps/search/patient/PatientCriteria/BasicInformation.spec.tsx index 5645601f86..f026ebebae 100644 --- a/apps/modernization-ui/src/apps/search/patient/PatientCriteria/BasicInformation.spec.tsx +++ b/apps/modernization-ui/src/apps/search/patient/PatientCriteria/BasicInformation.spec.tsx @@ -4,7 +4,6 @@ import { FormProvider, useForm } from 'react-hook-form'; import { BasicInformation } from './BasicInformation'; import { PatientCriteriaEntry } from '../criteria'; import { SkipLinkProvider } from 'SkipLink/SkipLinkContext'; -import { error } from 'console'; const mockAllows = jest.fn(); @@ -12,9 +11,9 @@ jest.mock('libs/permission/usePermissions', () => ({ usePermissions: () => ({ permissions: [], allows: mockAllows }) })); -const Fixture = () => { +const Fixture = ({ mode }: { mode?: 'onChange' | 'onBlur' }) => { const form = useForm({ - mode: 'onChange', + mode: mode ?? 'onChange', defaultValues: { status: [{ name: 'Active', label: 'Active', value: 'ACTIVE' }] } }); @@ -79,4 +78,20 @@ describe('when Basic information renders', () => { expect(errorMessage).toHaveTextContent('The Date of birth should have a month between'); expect(errorMessage).toHaveTextContent('The Date of birth should be at least'); }); + + it('should not show an error message when unchecking all status boxes then tabbing to next checkbox', async () => { + mockAllows.mockReturnValue(true); + const { getByRole, queryByRole } = render(); + + const user = userEvent.setup(); + + const statusCheckbox = getByRole('checkbox', { name: 'Active' }); + expect(statusCheckbox).toBeChecked(); + await user.click(statusCheckbox); + expect(statusCheckbox).not.toBeChecked(); + await user.tab(); + + const errorMessage = queryByRole('alert'); + expect(errorMessage).not.toBeInTheDocument(); + }); });