Skip to content

Commit 2a6a041

Browse files
authored
(chore) Bump @carbon/react and core OpenMRS dependencies (#484)
Bumps @carbon/react to `^v1.76.0`, aligning the dependency version with the version we're pointing to in Core and everywhere else. Additionally, this adds an aria-label to the dropdown component to ensure that it remains accessible in tests using accessibility roles.
1 parent 36f51c8 commit 2a6a041

4 files changed

Lines changed: 613 additions & 573 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"access": "public"
3030
},
3131
"dependencies": {
32-
"@carbon/react": "1.74.0",
32+
"@carbon/react": "^1.76.0",
3333
"classnames": "^2.5.1",
3434
"lodash-es": "^4.17.21",
3535
"react-error-boundary": "^4.0.13",

src/components/inputs/select/dropdown.component.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { useTranslation } from 'react-i18next';
33
import { Dropdown as DropdownInput, Layer } from '@carbon/react';
44
import { shouldUseInlineLayout } from '../../../utils/form-helper';
55
import { isTrue } from '../../../utils/boolean-utils';
6+
import { isEmpty } from '../../../validators/form-validator';
7+
import { NullSelectOption } from '../../../constants';
68
import { type FormFieldInputProps } from '../../../types';
9+
import { useFormProviderContext } from '../../../provider/form-provider';
710
import FieldValueView from '../../value/view/field-value-view.component';
811
import FieldLabel from '../../field-label/field-label.component';
9-
import { useFormProviderContext } from '../../../provider/form-provider';
10-
import { NullSelectOption } from '../../../constants';
11-
import { isEmpty } from '../../../validators/form-validator';
1212
import styles from './dropdown.scss';
1313

1414
const Dropdown: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings, setFieldValue }) => {
@@ -62,16 +62,17 @@ const Dropdown: React.FC<FormFieldInputProps> = ({ field, value, errors, warning
6262
<div className={styles.boldedLabel}>
6363
<Layer>
6464
<DropdownInput
65+
aria-label={t(field.label)}
66+
disabled={field.isDisabled}
6567
id={field.id}
66-
titleText={<FieldLabel field={field} />}
68+
invalid={errors.length > 0}
69+
invalidText={errors[0]?.message}
6770
items={items}
6871
itemToString={itemToString}
69-
selectedItem={isEmpty(value) ? NullSelectOption : value}
7072
onChange={handleChange}
71-
disabled={field.isDisabled}
7273
readOnly={isTrue(field.readonly)}
73-
invalid={errors.length > 0}
74-
invalidText={errors[0]?.message}
74+
selectedItem={isEmpty(value) ? NullSelectOption : value}
75+
titleText={<FieldLabel field={field} />}
7576
warn={warnings.length > 0}
7677
warnText={warnings[0]?.message}
7778
/>

src/form-engine.test.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('Form engine component', () => {
248248

249249
await assertFormHasAllFields(screen, [
250250
{ fieldName: 'When was the HIV test conducted? *', fieldType: 'date' },
251-
{ fieldName: 'Community service delivery point *', fieldType: 'select' },
251+
{ fieldName: 'Community service delivery point', fieldType: 'select' },
252252
]);
253253

254254
try {
@@ -408,7 +408,7 @@ describe('Form engine component', () => {
408408
{ fieldName: 'If Unscheduled, actual number scheduled date *', fieldType: 'number' },
409409
{ fieldName: 'If Unscheduled, actual text area scheduled date *', fieldType: 'textarea' },
410410
{ fieldName: 'Not required actual text area scheduled date', fieldType: 'textarea' },
411-
{ fieldName: 'If Unscheduled, actual scheduled reason select *', fieldType: 'select' },
411+
{ fieldName: 'If Unscheduled, actual scheduled reason select', fieldType: 'select' },
412412
{ fieldName: 'If Unscheduled, actual scheduled reason multi-select *', fieldType: 'checkbox-searchable' },
413413
{ fieldName: 'If Unscheduled, actual scheduled reason radio *', fieldType: 'radio' },
414414
]);
@@ -703,6 +703,17 @@ describe('Form engine component', () => {
703703
});
704704

705705
describe('Default values', () => {
706+
let originalConsoleError;
707+
708+
beforeEach(() => {
709+
originalConsoleError = console.error;
710+
console.error = jest.fn();
711+
});
712+
713+
afterEach(() => {
714+
console.error = originalConsoleError;
715+
});
716+
706717
it('should initialize fields with default values', async () => {
707718
const saveEncounterMock = jest.spyOn(api, 'saveEncounter');
708719

0 commit comments

Comments
 (0)