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
  • 1
    Do you have the LockerService enabled in your sandbox? It looks like Rich Text Fields are disabled if LockerService is enabled. releasenotes.docs.salesforce.com/en-us/spring17/release-notes/…
    – Kyle
    Jan 9, 2017 at 22:32
  • @Kyle We have LockerService disabled and we are on Spring 17, where according to this page, any issues should be resolved; success.salesforce.com/issues_view?id=a1p3A0000001BrF Jan 9, 2017 at 22:40
  • This might not be it, but I'll throw it out here anyway... If you use a custom afterRender, make sure you're calling this.superAfterRender(). I've been bit by not calling this, and then some of my custom input fields appear not to work, and I waste a couple hours figuring it out. Finally put a sticky note on my monitor to remind me. Jan 9, 2017 at 23:59
  • Can you try binding your update on keyup instead of update. peterknolle.com/lightning-input-component-value-binding
    – manjit5190
    Jan 10, 2017 at 3:44
  • 1
    Yes Its working Fine!!!...Error was on my side..Binding with correct variable solved this for me..Thanks @joshuadelange.. Feb 25, 2018 at 11:36

2 Answers 2

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

You must log in to answer this question.

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