SatcherInstitute / health-equity-tracker

Health Equity Tracker is a free-to-use data visualization platform that is enabling new insights into the impact of COVID-19 and other social and political determinants of health on historically underrepresented groups in the United States.
https://healthequitytracker.org/
MIT License
17 stars 24 forks source link

Fix a11y of `<CombinedLink />` component #3711

Open benhammondmusic opened 2 weeks ago

benhammondmusic commented 2 weeks ago

Describe the bug

The CombinedLink component is causing the biome linter to fail, as it's breaking some a11y rules.

I have temporarily added ignore comments to allow it to pass, but we need to fix this the right way, which likely will be rendering a <button> component which is the proper semantic element for an interactive item, and then overriding the styles to allow it to look like the text link it is now and not like a goofy button with the browser default styles

function CombinedLink(props: CombinedLinkProps) {
  const { to, isScrollLink, children, ...rest } = props
  const scrollToAnchor = useScrollToAnchor()

  if (isScrollLink) {
    return (
      // TODO: fix a11y
      // biome-ignore lint/a11y/useFocusableInteractive: <explanation>
      // biome-ignore lint/a11y/useSemanticElements: <explanation>
      <div onClick={() => scrollToAnchor(to)} role='link' {...rest}>
        {children}
      </div>
    )
  }
  return null
}

frontend/src/styles/HetComponents/HetOnThisPageMenu.tsx