Skip to content
Snippets Groups Projects
Commit 116e8e74 authored by chris's avatar chris
Browse files

set multiple choice aria-label

parent b76db752
No related branches found
No related tags found
1 merge request!479set multiple choice aria-label
......@@ -43,7 +43,9 @@ const Label = styled.label`
`;
const SwitchComponent = props => {
const { className, label, labelPosition, onChange, ...rest } = props;
const { className, label, labelPosition, onChange, text, ...rest } = props;
const ariaLabel = `Is it correct ${text}`;
return (
<Wrapper className={className}>
......@@ -53,7 +55,7 @@ const SwitchComponent = props => {
</Label>
)}
<Switch aria-label="Is it correct" onChange={onChange} {...rest} />
<Switch aria-label={ariaLabel} onChange={onChange} {...rest} />
{label && labelPosition === 'right' && (
<Label labelPosition={labelPosition} onClick={onChange}>
......
......@@ -6,6 +6,7 @@ const CustomSwitch = ({ node, getPos }) => {
const context = useContext(WaxContext);
const [checked, setChecked] = useState(false);
const [checkedAnswerMode, setCheckedAnswerMode] = useState(false);
const {
pmViews: { main },
} = context;
......@@ -45,6 +46,17 @@ const CustomSwitch = ({ node, getPos }) => {
});
};
const getUpdatedNode = () => {
let nodeFound = node;
const allNodes = getNodes(main);
allNodes.forEach(singNode => {
if (singNode.node.attrs.id === node.attrs.id) {
nodeFound = singNode;
}
});
return nodeFound;
};
return (
<YesNoSwitch
checked={checked}
......@@ -52,7 +64,7 @@ const CustomSwitch = ({ node, getPos }) => {
customProps={customProps}
handleChange={handleChange}
isEditable={isEditable}
node={node}
node={getUpdatedNode()}
/>
);
};
......
......@@ -44,7 +44,7 @@ const StyledIconWrong = styled(Icon)`
`;
const YesNoSwitch = ({
customProps,
node,
node: { node },
isEditable,
handleChange,
checked,
......@@ -83,6 +83,7 @@ const YesNoSwitch = ({
label="Correct?"
labelPosition="left"
onChange={handleChange}
text={node.textContent}
unCheckedChildren="NO"
/>
);
......
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