Adobe-CEP / CEP-Resources

Tools and documentation for building Creative Cloud app extensions with CEP
https://www.adobe.io/apis/creativecloud/cep.html
1.63k stars 830 forks source link

CEP 11 (InDesign 16.4) <input> in shadowRoot not working #410

Open LSeawalker opened 3 years ago

LSeawalker commented 3 years ago

Since the new CEP 11 uses a very recent Chromium version, we tried to use our shadow-dom-based web application. But some of our <input> elements are located in a shadowRoot. In the InDesign extension it is not possible to type any characters in that input element. It seems that InDesign checks if document.activeElement is an <input> element. But because of the shadow-dom, the activeElement is the most outer wrapper which contains a shadow root (e.g. <my-input>) So all of the inputs are caught by InDesign itself for its shortcuts.

We use an open shadowRoot, so it could be possible to check for a shadowRoot of document.activeElement and check recursivly its activeElements.

<body>
  <outer-element>
    #shadow-root
      <inner-element>
        #shadow-root
          <input>

=> document.activeElement.shadowRoot.activeElement.shadowRoot.activeElement === input

Anyway, we also want to bind some internal extension shortcuts outside of an input field (e.g. ctrl + f to find some data on the server). I think it would be nice if there was a way to tell that "these keyboard events were caught by my extension" and InDesign will not receive them

LSeawalker commented 3 years ago

We have solved our problem by using "registerKeyEventsInterest" (we have only just come across this function) and generate an array of all key combinations. It would be nice if there was also an "unregister" method, but catching all key combinations is enough for us for now.