communitiesuk / gov-uk-dash-react-components

GovUK React components for Dash - GDS. This also includes autocomplete
Other
9 stars 1 forks source link

Handle arrow key events in the accordion component #64

Closed Ellie-Brakoniecki closed 1 year ago

Ellie-Brakoniecki commented 1 year ago

Also fix problem uncovered by Wave by linking giving the accordion content the id of the aria-controls button

Note: Need to test elements are selected visually as Narrator is intercepting keyboard events.

Jordan-Hall commented 1 year ago

Instead of doing document.query which will grab a single accordant which prevents multiple being used on the same screen const accordRef = useRef(null);

and then in the template use <div ref={accordRef } ...

You can use multiple regs to grab elements so maybe a better idea so you don't have huge clashes :)

Edit:

React.createRef() is the correct way as its a class version https://legacy.reactjs.org/docs/refs-and-the-dom.html

Thanks Jordan for these suggestions - we've made these changes:) Ellie