I cannot press backspace in a <div contenteditable="true" /> in Service console. I would like to.

The reason, as far as I can tell, is that in ServiceDeskViewCTI.js, there's the following line of JS:

Sfdc.on(document, "keydown", function(a) {
    var b = document.activeElement ? document.activeElement.tagName.toUpperCase() : !1;
    !("INPUT" === b || "TEXTAREA" === b) && 8 === a.keyCode && Sfdc.Event.preventDefault(a)

I think I have seen similar code elsewhere referencing the method Sfdc.support.servicedesk.isInputFocused, which similarly defines an input as <input> or <textarea>.

How do I solve this?


While writing up this question, I did discover an answer, but perhaps not the best. I added the following to my code (I was already using jQuery):

  $('[contenteditable=true]').keydown(function (e) {

This stops the event from propagating to the document where Salesforce binds the method that calls preventDefault.

  • I had similar issue when using formbuilder.online in my website and your fix worked! thank you. – hriziya Jun 14 '19 at 13:27

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.