Skip to content
Snippets Groups Projects
Commit 3c5fd6c3 authored by chris's avatar chris
Browse files

add ids

parent 1fc2a595
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,7 @@ const StyledIcon = styled(Icon)` ...@@ -65,7 +65,7 @@ const StyledIcon = styled(Icon)`
margin-left: auto; margin-left: auto;
`; `;
const DropComponent = ({ getPos, node, view }) => { const DropComponent = ({ getPos, node, view, uniqueId }) => {
const [selectedOption, setSelectedOption] = useState(node.attrs.correct); const [selectedOption, setSelectedOption] = useState(node.attrs.correct);
const itemRefs = useRef([]); const itemRefs = useRef([]);
const wrapperRef = useRef(); const wrapperRef = useRef();
...@@ -156,7 +156,7 @@ const DropComponent = ({ getPos, node, view }) => { ...@@ -156,7 +156,7 @@ const DropComponent = ({ getPos, node, view }) => {
return ( return (
<Wrapper disabled={isDisabled} ref={wrapperRef}> <Wrapper disabled={isDisabled} ref={wrapperRef}>
<DropDownButton <DropDownButton
aria-controls="options-list" aria-controls={uniqueId}
aria-expanded={isOpen} aria-expanded={isOpen}
aria-haspopup aria-haspopup
disabled={isDisabled} disabled={isDisabled}
...@@ -172,6 +172,7 @@ const DropComponent = ({ getPos, node, view }) => { ...@@ -172,6 +172,7 @@ const DropComponent = ({ getPos, node, view }) => {
} }
}} }}
onMouseDown={openCloseMenu} onMouseDown={openCloseMenu}
role="combobox"
type="button" type="button"
> >
{selectedOption === null || !selectedOption {selectedOption === null || !selectedOption
...@@ -181,7 +182,7 @@ const DropComponent = ({ getPos, node, view }) => { ...@@ -181,7 +182,7 @@ const DropComponent = ({ getPos, node, view }) => {
</DropDownButton> </DropDownButton>
<DropDownMenu <DropDownMenu
aria-label="Choose an option" aria-label="Choose an option"
id="options-list" id={uniqueId}
isOpen={isOpen} isOpen={isOpen}
role="listbox" role="listbox"
> >
...@@ -189,11 +190,12 @@ const DropComponent = ({ getPos, node, view }) => { ...@@ -189,11 +190,12 @@ const DropComponent = ({ getPos, node, view }) => {
itemRefs.current[index] = itemRefs.current[index] || createRef(); itemRefs.current[index] = itemRefs.current[index] || createRef();
return ( return (
<span <span
aria-selected={option.value === selectedOption}
key={option.value} key={option.value}
onClick={() => onChange(option)} onClick={() => onChange(option)}
onKeyDown={e => onKeyDown(e, index)} onKeyDown={e => onKeyDown(e, index)}
ref={itemRefs.current[index]} ref={itemRefs.current[index]}
role="menuitem" role="option"
tabIndex="-1" tabIndex="-1"
> >
{option.label} {option.label}
......
...@@ -141,7 +141,12 @@ export default ({ node, view, getPos }) => { ...@@ -141,7 +141,12 @@ export default ({ node, view, getPos }) => {
<EditorComponent getPos={getPos} node={node} view={view} /> <EditorComponent getPos={getPos} node={node} view={view} />
<DropDownContainer> <DropDownContainer>
{(!readOnly || (readOnly && !testMode && !showFeedBack)) && ( {(!readOnly || (readOnly && !testMode && !showFeedBack)) && (
<DropDownComponent getPos={getPos} node={node} view={view} /> <DropDownComponent
getPos={getPos}
uniqueId={uuidv4()}
node={node}
view={view}
/>
)} )}
{readOnly && testMode && !showFeedBack && ( {readOnly && testMode && !showFeedBack && (
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment