0

I have a custom Lightning component. I tried adding a <lightning:inputRichText> component to it, as per the Spring '17 Release Notes. However, when the page renders, I get a partially rendered rich text box:

And when I click on the empty buttons I get an error:

My code is pretty simple:

RichTextSample.cmp

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <aura:attribute name="myVal" type="String" default="&lt;b>Hello&lt;/b>"/> 
    <lightning:inputRichText value="{!v.myVal}" placeholder="Type something interesting">
    </lightning:inputRichText>
    <div aura:id="output" class="slds-box slds-text-longform">
        <ui:outputRichText value="{!v.myVal}" />
    </div>
</aura:component>

RichTextSampleRenderer.js

({
    'afterRender': function(){
        // do some dynamic stuff after the component has rendered
    }
})
0

After struggling with this for a couple hours, I finally discovered that the issue is a missing call to superAfterRender(). The documentation I found doesn't explicitly state that this call is required, though in retrospect it's clearly hinted at. It appears that rich text components (and quite probably others) need this call to finish rendering.

My corrected component code looks like this:

RichTextSample.cmp

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global" >
    <aura:attribute name="myVal" type="String" default="&lt;b>Hello&lt;/b>"/> 
    <lightning:inputRichText value="{!v.myVal}" placeholder="Type something interesting">
    </lightning:inputRichText>
    <div aura:id="output" class="slds-box slds-text-longform">
        <ui:outputRichText value="{!v.myVal}" />
    </div>
</aura:component>

RichTextSampleRenderer.js

({
    'afterRender': function(){
        this.superAfterRender();
        // do some dynamic stuff after the component has rendered
    }
})
2
  • 2
    Only because you'd overrode it to begin with. If you didn't have a render file, it should work normally. – sfdcfox Dec 28 '17 at 20:31
  • Yes. This was an MVCE. – JDB still remembers Monica Dec 28 '17 at 21:13

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.