0
let editorContents = this.template.querySelector("lightning-input-rich-text.myclass").value;

the above line returns null when the contents of the editor has just one word. After I type a space the above line seems to return the actual content.

This definitely is a bug. So, what's the workaround for getting the actual value of the rich text editor without asking users to type a space?

1
  • 1
    This is interesting. Could you add the HTML markup (the lightning-input-rich-text element with all its attributes) and the complete event handler code to your question? With the most trivial setup (element has class and onchange handler) I can't reproduce the problem. My initial thought was that Salesforce forgot to declare the value attribute as mandatory, but it works for me without it. Commented Jul 12 at 8:40

1 Answer 1

0

This worked for me

HTML

 lightning-input-rich-text
        class="myclass"
        value={myVal}
        onchange={handleChange}>
    </lightning-input-rich-text>

JS:

    handleChange(event) {

        this.myVal = event.target.value;

        let editorContents = this.template.querySelector("lightning-input-rich-text.myclass").value;

        console.log('editorContents2=',editorContents);   //prints the value 
    }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .