Skip to content

Commit

Permalink
fix setContents loosing focus
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhstar committed Jun 6, 2021
1 parent 082d61b commit e07adc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "suneditor-react",
"version": "3.1.1",
"version": "3.1.2",
"description": "A React Component for Suneditor",
"repository": {
"type": "git",
Expand Down
5 changes: 4 additions & 1 deletion src/SunEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,15 @@ const SunEditor: FC<SunEditorReactProps> = (props) => {
}, [setDefaultStyle]);

useEffect(() => {
if (setContents !== undefined) editor.current?.setContents(setContents);
if (setContents !== undefined)
!editor.current?.core.hasFocus &&
editor.current?.setContents(setContents);
}, [setContents]);

useEffect(() => {
if (appendContents !== undefined)
editor.current?.appendContents(appendContents);
editor.current?.core.focusEdge(null);
}, [appendContents]);

useEffect(() => {
Expand Down

0 comments on commit e07adc5

Please sign in to comment.