+ Start a Discussion
Narsimha RaoNarsimha Rao 

lightning:inputRichText value losing HTML format when text is added.

Hello,

I'm building a dynamic HTML string in my helper class and assigning that string as value to lightning:inputRichText. When I add any text to lightning:inputRichText, the value which has the HTML tags is losing the tags. 

Here is a sample dynamic HTML string before adding input text to lightning:inputRichText.
<HTML ><strong><u>Quick Note Details</u></strong><br/>Type of Meeting: General Update<br/>Date: Dec 2, 2019<br/><br/><strong><u>Total Commitments </u></strong><br/>Direct Commitments: $5,098m<br/><br/><strong><u>Opportunities Discussed</u></strong><br/><p><b>SCRF IV (Closed, 125m)</b></p><p>Consultant: Abbott Capital Management (Consultant-led)<ul><li>Summary<ul><li>02-Dec-2019-Test Summary</li></ul></li></ul><br/><br/><strong><u>Organization Overview</u></strong><br/><!--Overview--><br/><br/><strong><u>Organization Details</u></strong><br/><strong>AUM (MM) [USD]: </strong>$110,000<br/><strong>Coverage: </strong><!--Coverage--><br/><strong>Secondary Coverage: </strong>Secondary Coverage<br/><br/><strong><u>Direct Commitments</u></strong><table></table><br/></HTML>
Here is the lightning:inputRichText statement in the component
<lightning:inputRichText value="{!v.emailBody}" label="Body" aura:id="editor" />

Here is HTML value after adding blank space to the input
<p><b><u>Quick Note Details</u></b></p><p>Type of Meeting: General Update</p><p>Date: Dec 2, 2019</p><p><br></p><p><b><u>Total Commitments </u></b></p><p>Direct Commitments: $5,098m</p><p><br></p><p><b><u>Opportunities Discussed</u></b></p><p><b>SCRF IV (Closed, 125m)</b></p><p>Consultant: Abbott Capital Management (Consultant-led)</p><ul><li>Summary<ul><li>02-Dec-2019-Test Summary</li></ul></li></ul><p><br></p><p><br></p><p><b><u>Organization Overview</u></b></p><p><!--Overview-->.</p><p><br></p><p><b><u>Organization Details</u></b></p><p><b>AUM (MM) [USD]: </b>$110,000</p><p><b>Coverage: </b><!--Coverage--></p><p><b>Secondary Coverage: </b>Secondary Coverage</p><p><br></p><p><b><u>Direct Commitments</u></b></p><table></table><p><br></p>

How can I avoid the above from happening? I just want the value to retain the HTML tags and not lose the format.


 
JUAN DÍAZJUAN DÍAZ
Same problem here, even using the LWC version of the component. ¿Any idea? This seems a bug.
James MorehouseJames Morehouse
I'm also having the same issues asn you. If I found any kinf of solution then I'll let you know Upsers (https://www.upsers.win/)
DaspereraDasperera
Hi Narsimha,

As it's mentioned in the https://salesforce.stackexchange.com/questions/242263/lightninginputrichtext-lightningformattedrichtext-isnt-working-with-email-t/242298 , if you include the <lightning:inputRichText> tag inside a <pre> tag this should work.
 
<pre><lightning:inputRichText aura:id="editor" value="{!v.emailBody}" label="Body"/></pre>