Skip to content

Commit

Permalink
(fix) Fix invalid prop warning for some Carbon components (#2048)
Browse files Browse the repository at this point in the history
(fix) Fix invalid prop warning for Carbon Components

This PR fixes the value passed as the `invalid` prop for several Carbon Components, ensuring that the value is always a boolean.
  • Loading branch information
denniskigen authored Oct 1, 2024
1 parent 20eb9f4 commit 15a2f3a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ const MarkPatientDeceasedForm: React.FC<DefaultPatientWorkspaceProps> = ({ close
render={({ field: { onChange, value } }) => (
<TextInput
id="freeTextCauseOfDeath"
invalid={errors?.nonCodedCauseOfDeath}
invalidText={errors?.nonCodedCauseOfDeath && errors?.nonCodedCauseOfDeath?.message}
invalid={!!errors?.nonCodedCauseOfDeath}
invalidText={errors?.nonCodedCauseOfDeath?.message}
labelText={t('nonCodedCauseOfDeath', 'Non-coded cause of death')}
onChange={onChange}
placeholder={t('enterNonCodedCauseOfDeath', 'Enter non-coded cause of death')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const VisitDateTimeField: React.FC<VisitDateTimeFieldProps> = ({
labelText={t('date', 'Date')}
placeholder="dd/mm/yyyy"
style={{ width: '100%' }}
invalid={errors[dateFieldName]?.message}
invalid={!!errors[dateFieldName]}
invalidText={errors[dateFieldName]?.message}
/>
</DatePicker>
Expand All @@ -84,7 +84,7 @@ const VisitDateTimeField: React.FC<VisitDateTimeFieldProps> = ({
style={{ marginLeft: '0.125rem', flex: 'none' }}
value={value}
onBlur={onBlur}
invalid={errors[timeFieldName]?.message}
invalid={!!errors[timeFieldName]}
invalidText={errors[timeFieldName]?.message}
>
<Controller
Expand All @@ -96,7 +96,7 @@ const VisitDateTimeField: React.FC<VisitDateTimeFieldProps> = ({
onChange={(event) => onChange(event.target.value as amPm)}
value={value}
aria-label={t('timeFormat ', 'Time Format')}
invalid={errors[timeFormatFieldName]?.message}
invalid={!!errors[timeFormatFieldName]}
invalidText={errors[timeFormatFieldName]?.message}
>
<SelectItem value="AM" text="AM" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function LabOrderForm({
value={value}
onChange={onChange}
onBlur={onBlur}
invalid={errors.accessionNumber?.message}
invalid={!!errors.accessionNumber}
invalidText={errors.accessionNumber?.message}
/>
)}
Expand All @@ -216,7 +216,7 @@ export function LabOrderForm({
items={priorityOptions}
onBlur={onBlur}
onChange={({ selectedItem }) => onChange(selectedItem?.value || '')}
invalid={errors.urgency?.message}
invalid={!!errors.urgency}
invalidText={errors.urgency?.message}
/>
)}
Expand All @@ -241,7 +241,7 @@ export function LabOrderForm({
items={orderReasons}
onBlur={onBlur}
onChange={({ selectedItem }) => onChange(selectedItem?.uuid || '')}
invalid={errors.orderReason?.message}
invalid={!!errors.orderReason}
invalidText={errors.orderReason?.message}
/>
)}
Expand All @@ -266,7 +266,7 @@ export function LabOrderForm({
onChange={onChange}
onBlur={onBlur}
maxCount={500}
invalid={errors.instructions?.message}
invalid={!!errors.instructions}
invalidText={errors.instructions?.message}
/>
)}
Expand Down

0 comments on commit 15a2f3a

Please sign in to comment.