Skip to content

Commit

Permalink
chore: fix rich text editor
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Sep 22, 2023
1 parent f70220e commit 9b20948
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/components/TextResponse/RichTextEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ const RichTextEditor = ({
toolbar: 'formatselect | bold italic underline | link blockquote image | numlist bullist outdent indent | strikethrough | code | undo redo',
};

const handleChange = (e) => {
onChange(e.target.getContent());
};

return (
<div className="form-group">
<label htmlFor="rich-text-response">
Expand All @@ -53,7 +49,7 @@ const RichTextEditor = ({
plugins: 'code image link lists',
...extraConfig,
}}
onChange={handleChange}
onEditorChange={onChange}
disabled={disabled}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextResponse/RichTextEditor.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('<RichTextEditor />', () => {
optional: true,
disabled: false,
value: 'value',
onChange: jest.fn(),
onChange: jest.fn().mockName('onChange'),
};

it('render optional', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`<RichTextEditor /> render disabled 1`] = `
}
}
name="rich-text-response"
onChange={[Function]}
onEditorChange={[MockFunction onChange]}
value="value"
/>
</div>
Expand Down Expand Up @@ -61,7 +61,7 @@ exports[`<RichTextEditor /> render optional 1`] = `
}
}
name="rich-text-response"
onChange={[Function]}
onEditorChange={[MockFunction onChange]}
value="value"
/>
</div>
Expand Down Expand Up @@ -94,7 +94,7 @@ exports[`<RichTextEditor /> render required 1`] = `
}
}
name="rich-text-response"
onChange={[Function]}
onEditorChange={[MockFunction onChange]}
value="value"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/views/SubmissionView/SubmissionContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const SubmissionContent = ({
<TextResponse
submissionConfig={oraConfigData.submissionConfig}
value={submission.response.textResponses[index]}
onChange={(value) => onTextResponseChange(value, index)}
onChange={onTextResponseChange(index)}
/>
</div>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/views/SubmissionView/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const useSubmissionViewHooks = () => {
}
}, [pageData?.submission]);

const onTextResponseChange = (textResponse, index) => {
const onTextResponseChange = (index) => (textResponse) => {
dispatchSubmission({
response: {
...submission.response,
Expand Down

0 comments on commit 9b20948

Please sign in to comment.