0

Adding a placeholder in lightning-textarea is causing the triggering of onchange event on it in the IE browser.

Below is the snippet where I have added placeholder = "Enter value". While loading the component in LWC, it is causing triggering of the onchange = {handleChange} event. I need to stop this as further validations are there on the change event.

<lightning-textarea value={TestValue}
                      class="requiredField" 
                      placeholder="Enter value"
                      onchange={handleChange} 
                      message-when-value-missing="Please Enter the value"
                      variant="label-hidden"
                      max-length=50
                      required>
              </lightning-textarea>
1
  • 1
    I think it's worth noting that Lightning Experience is not fully supported in Internet Explorer and Salesforce support ends at the end of this year. You're going to be facing constant uphill battles trying to support it. LWCs are actually transpiled into an ES5 format for old browsers like IE which is likely where the issue is coming from (placeholder should be a valid attribute even in IE11 I would think). help.salesforce.com/…
    – nbrown
    Aug 11 '20 at 12:49
0

You can try following workaround in Your handler:

handleChange(event) {
    if(event.target.value !== 'Enter value') {
    //Your logic here
    }
}
1
  • event.target.value is ''(emptystring) as placeholder is not set to value attribute. Aug 11 '20 at 13:02

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.