Skip to content

Ensure all components can accept an id attribute #2308

@dylankenneally

Description

@dylankenneally

We've noticed that we're not able to set an id on some HIG elements, such as <Accordion> ("@hig/accordion": "^1.1.1",), so we've been wrapping these as follows:

export default function AccordionWrapper({ id, label, children, className = undefined }) {
	// span is because HIG's accordion doesn't support setting an ID
	return <span id={id}>
		<Accordion label={label} defaultCollapsed={isCollapsed(id)} onClick={() => storeInvertedCollapsed(id)} className={className || ''}>
			{children}
		</Accordion>
	</span>;
}

To be done

  1. review the existing components' application of id attributes
  2. form a list of elements that do not permit the id attribute to be set
  3. apply the existing pattern found in pt 1 above to the items in pt 2
  4. apply unit tests as appropriate

cc: @wmui51, re: slack converstion about this issue

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions