Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while using setContents #543

Closed
dgandhi1993 opened this issue Nov 1, 2020 · 5 comments
Closed

Error while using setContents #543

dgandhi1993 opened this issue Nov 1, 2020 · 5 comments
Labels
Milestone

Comments

@dgandhi1993
Copy link

Hi @JiHong88

I am facing this issue for quite some time now, however, I am not able to figure out the root cause.

When I try to set my editor's content using setContents(), I get below error:

Uncaught TypeError: Cannot read property 'scrollTop' of null
    at Object.getOffset (util.js:1021)
    at Object.setControllerPosition (core.js:755)
    at Object.call_controller (math.js:244)
    at Object.active (math.js:215)
    at Object._applyTagEffects (core.js:5305)
    at Object._onChange_historyStack (core.js:5011)
    at h (history.js:86)
    at Object.push (history.js:109)
    at Object.setContents (core.js:4411)
    at Object.setContents (core.js:7448)

The same code usually works fine, but at times gives the above error.
Once this code breaks, my entire business logic in its parent function stops.

Can you help rectify this edge case?

@JiHong88
Copy link
Owner

JiHong88 commented Nov 1, 2020

@dgandhi1993 When is "setContents" called?
And show me the contents of "setContents".

@dgandhi1993
Copy link
Author

setContents is called with an empty string long after the editor instance initialization.

Basically, I am trying to clear the editor's content.

@JiHong88
Copy link
Owner

JiHong88 commented Nov 2, 2020

@dgandhi1993 If you are trying to set the initial values of the editor, you should do it in one of three ways:

  1. call setContents inside onload
    instance.onload = (core) => core.setContents("");

  2. value option
    suneditor.create("id", {value: ""})

  3. just empty textarea

<textarea><textarea>

@dgandhi1993
Copy link
Author

@JiHong88 I am using the value property. This issue appears when I am trying to change an existing editor instance value.
Also, this doesn't happen always.

@JiHong88 JiHong88 added the bug label Nov 3, 2020
@JiHong88 JiHong88 added this to the 2.35.0 milestone Nov 3, 2020
JiHong88 added a commit that referenced this issue Nov 3, 2020
@JiHong88 JiHong88 closed this as completed Nov 3, 2020
@JiHong88
Copy link
Owner

The 2.34.2 version has been updated.
If this issue has not been resolved, please reopen this issue.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants