Skip to content

Commit e526160

Browse files
committed
bugfix: handle onCLose for IPRWYSIWGEditor properly
DEVSU-2599
1 parent 43e4a42 commit e526160

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/components/IPRWYSIWYGEditor/index.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,21 @@ const IPRWYSIWYGEditor = ({
194194
}
195195
}, [editor, onClose]);
196196

197+
const handleOnClose = useCallback(() => {
198+
onClose(null);
199+
// Reset the editor text, since we don't deal with the state in React
200+
editor.commands.setContent(text);
201+
}, [onClose, editor, text]);
202+
197203
return (
198-
<Dialog fullWidth maxWidth="lg" open={isOpen} onClose={() => onClose(null)}>
204+
<Dialog fullWidth maxWidth="lg" open={isOpen} onClose={handleOnClose}>
199205
<DialogTitle>{title}</DialogTitle>
200206
<DialogContent>
201207
<MenuBar editor={editor} className="IPRWYSIWYGEditor__toolbar" />
202208
<EditorContent editor={editor} className="IPRWYSIWYGEditor__content" />
203209
</DialogContent>
204210
<DialogActions>
205-
<Button onClick={() => onClose(null)}>Close</Button>
211+
<Button onClick={handleOnClose}>Close</Button>
206212
<Button color="secondary" onClick={handleOnSave}>Save</Button>
207213
</DialogActions>
208214
</Dialog>

0 commit comments

Comments
 (0)