3

Since Spring 17 my input rich text field is not updating the value anymore when I change the value.

See the following code:

 <ui:inputText label="{!v.label}" value="{!v.value}" change="{!c.onInputFieldChange}" />
 <ui:inputRichText label="{!v.label}" cols="50" rows="5" value="{!v.value}" change="{!c.onInputFieldChange}"/>

When I type into the inputText field, the value updates fine and updates in the inputRichText field as well. It does not work the other way around.

Am I doing something completely wrong, or is this a bug in Lightning? As far as I can tell, this was working before our sandbox switched to Spring 17.

16
0

Seems like potentially a life-cycle issue / native component / quill not destroying correctly. At least in my case, the below seemed to help:

[EDIT] Sorry but after many hours of experimentation I need to refine my answer. The only way I could get the value of lightning:inputRichText to display in all situations was defer the rendering of the component until after the value it was bound to was set.

    --- component ---
<!--
- *note*  even though we want this component to always render we are using a conditional
- so that rendering is deferred (while in Edit mode) until after the sObject is retrieved in order
- to resolve the issue. of edit sObject / destroy component.. edit sObject again. component
- does not properly display the note body upon second edit.'
-
- renderRTE is set to true in 2 use cases...
- 1. CREATE MODE - immediately in init when we want to insert a new sObject.
- 2. EDIT MODE - (Deferred) in the helper callback (fired from init)..after retrieving the sObject.
- (after v.svcNote is initialized with either a blank value if no note exists or
- or the existing sObject Note.body of the note associated with the sObject.
-->
<aura:if isTrue="{!v.renderRTE}">
    <lightning:inputRichText aura:id="inputRT" value="{!v.svcNote.Body}"/> 
</aura:if>

--- controller ----
doInit : function(cmp, evt, helper) {
    if (isCreateMode) {
        cmp.set('v.renderRTE', true);
    } else {
        helper.retrieveSObjectData();
    }
}
---- helper ---
retrieveSObjectData: function(cmp,helper) {
    var action=cmp.get('c.retrieveSvcAndNote');
    action.setCallback(this, function(response) {
        cmp.set("v.svcNote",
            {
                "sobjectType": "Note",
                "Id":response.Id,
                "Title": response.Title,
                "ParentId": response.ParentId,
                "Body": response.Body
            }
        );
        cmp.set('v.renderRTE',true);
    });
    $A.enqueueAction(action);
),
0

Salesforce has fixed this issue in one of their latest updates.

I'm now using the lightning:inputRichText successfully:

<lightning:inputRichText value="{!v.myVal}" />

Docs: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_inputRichText.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.