0

I have a lightning component that provides it's own hotkeys and those are now overlapping with the new LEX hotkeys released in Summer '17. So pressing 'e' pops open the LEX edit, when i'd like to do something else. Salesforce also kills all propigation so my listener doesn't even get a chance to react. I'd like to disable the LEX hotkeys or better yet find a way to avoid triggering them when my component isRendered().

This is a long shot - I've already dug through the javascript and am pretty sure it's impossible.

  • Can confirm its impossible from lightening components, you can do this from Chrome extension or Tampermonkey, this is not a salesforce solution though. – Prafulla Patil Jul 11 '17 at 20:05
4

Alright - Suuuuper hacky, but I found a way. There is some code in keyComboProcessor.js _isEditingText() that checks a few ways the user could be editing. If you match these with your focused element you can sneak around the handler.

_isEditingText:function(keyboardEvent) {
    var targetElmt = keyboardEvent.target;
    if(targetElmt.tagName === "INPUT") {
      return!!EDITING_INPUT_TYPES[targetElmt.type]
    }
    if(targetElmt.tagName === "TEXTAREA") {
      return true
    }
    if(targetElmt.tagName === "DIV" && targetElmt.className) {
      return targetElmt.className.indexOf("cke_editable") !== -1 || targetElmt.className.indexOf("ql-editor") !== -1
    }
    if(targetElmt.tagName === "A") {
      return targetElmt.className.indexOf("select") !== -1 || !!(targetElmt.getAttribute("role") && targetElmt.getAttribute("role").indexOf("menuitem") !== -1)
    }
    return false
  }

For me, I just focused a DIV with a tabindex and gave it the cke_editable class.

  • This worked great for me, thanks for finding this. I have a div with contentEditable = true and was having an issue with e and / firing Salesforce shortcuts. Adding cke_editable to the div stopped all Salesforce shortcuts – Benjamin Vogler Jul 10 '19 at 18:47

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.