jqueryblocklygoogle-blockly

Google Blockly UI on jQuery Dialog is not editable


While rendering Blockly UI in jQuery Dialog, it does not allow to edit the inputs.

Blockly UI IN Jquery Dialog

Reason is Blockly adding a div to DOM with an input field like below:

<div class="blocklyWidgetDiv" style="direction: ltr; display: block; left: 514.052px; top: 133.094px; width: 91.5547px;">
  <input class="blocklyHtmlInput" value="dfgfdgdfgdfg">
</div>

But the actual blocklyDiv is attached under jQuery Dialog. Input field directly attached to html body.

When I am moving the blocklyWidgetDiv inside Dialog, it showing input field some where in the page, not rendered in exact editor place.

enter image description here


Solution

  • I meanwhile found and solved the problem on my side.

    TL;DR: one of the containers of the Blockly workspace had a zoom factor different from 1 which was the reason for the wrong size and position of any input elements!

    Longer explanation

    Blockly overlays SVG display regions within its workspace by HTML form elements during input. While the workspace may be found anywhere deep in a document, the input element is placed in a direct child of the document body (and positioned absolutely depending on the SVG region's position). If any workspace parent has a zoom factor different from 1, the calculated position differs from the actual one and the input element is misplaced

    Possible solutions

    Unfortunately, I had to choose the last one.

    What I did:

    The result is a weird hack which is why I would like not to show the code to the public - in the long time, I would definitely recommend to place form elements closer to the Blockly workspace...

    Edit:

    unfortunately, this hack does not handle the problems which occur when trying to drag blocks into the trashcan with zoom factors much larger than 1.