Skip to content

Commit

Permalink
Fix issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbouder committed Dec 10, 2024
1 parent 334b6f9 commit 5452644
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const ComboBox = ({

const comboBoxAttributes: {
className: string;
ref: RefObject<HTMLDivElement>;
ref: RefObject<HTMLDivElement | null>;
'data-placeholder'?: string;
'data-default-value'?: unknown;
} = {
Expand Down
14 changes: 11 additions & 3 deletions packages/comet-uswds/src/components/form-group/form-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ export const FormGroup = ({
}

// Get the id of the fieldControl element associated with the label
let fieldControlId = isValidElement(fieldControl) ? fieldControl.props.id : undefined;
const fieldControlElement = isValidElement(fieldControl)
? (fieldControl as React.ReactElement)
? (fieldControl as React.ReactElement<{
id?: string;
className?: string;
children?: ReactNode;
}>)
: undefined;
let fieldControlId = fieldControlElement?.props?.id;

let fieldControlWithProps = fieldControlElement;
const fieldControlClass = fieldControlWithProps?.props.className;
Expand All @@ -95,7 +99,11 @@ export const FormGroup = ({
fieldControlClass === 'usa-date-picker'
) {
const children = fieldControlElement?.props.children;
fieldControlId = children?.props.id;
if (
isValidElement(children) ? (children as React.ReactElement<{ id?: string }>).props.id : false
) {
fieldControlId = (children as React.ReactElement<{ id?: string }>).props.id;
}
} else {
// Otherwise, we need to add aria-describedby to the fieldControl
if (fieldControlElement) {
Expand Down

0 comments on commit 5452644

Please sign in to comment.