diff --git a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/Switch.js b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/Switch.js index 1896a291388f8db837ccf5b6587d0d77b3b01e17..e88b3af8088c3a33bd053e0588bcffe161975099 100644 --- a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/Switch.js +++ b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/Switch.js @@ -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}> diff --git a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/SwitchComponent.js b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/SwitchComponent.js index cdf6481287a05ca6c69f508a1a919b8be9a42333..5261c7e9f2a3f19b7eb673635baf40a3f2793101 100644 --- a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/SwitchComponent.js +++ b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/SwitchComponent.js @@ -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()} /> ); }; diff --git a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/YesNoSwitch.js b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/YesNoSwitch.js index 7451482d3f36fbf62ecd28a69681b38b6b0cb5c3..6d847117a0457a783b5f16d7b2a00f4d7892c128 100644 --- a/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/YesNoSwitch.js +++ b/wax-prosemirror-services/src/MultipleChoiceQuestionService/components/YesNoSwitch.js @@ -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" /> );