Cannot type in Blockly workspace in Bootstrap modal

151 views
Skip to first unread message

francis_...@smartpixel.tv

unread,
Jul 26, 2018, 3:21:20 PM7/26/18
to Blockly

I'm having a problem with a Blockly workspace inside a Bootstrap modal.


Everything seems to work fine, but I cannot type in the inputs that I drag into the workspace.

If you look at the attached image, I'm trying to type into the highlighted block, but that doesn't work.

I had a problem previously where the workspace would not show if rendered inside a collapsed div. I fixed this by adding an event which fires when Step Formulas is clicked and execute the following code:

window.dispatchEvent(new Event('resize'));


I validated that if I place the div in which the workspace is injected into the main layout's HTML, it works fine. I can type.


Any ideas?


Thanks.

StepDialog.jpg

Rachel Fenichel

unread,
Jul 26, 2018, 4:11:53 PM7/26/18
to Blockly
We've had a lot of problems reported with Bootstrap integration.  It's often a problem with the z-index of various Blockly objects.  

The text editor that pops up over the field when you click is in the blocklyWidgetDiv.  Can you find that in your layout and see if it's there but just out of order somehow?

Here's the expected css: 
  .blocklyWidgetDiv {
    display: none;
    position: absolute;
    z-index: 99999; /* big value for bootstrap3 compatibility */
  }

Rachel

francis_...@smartpixel.tv

unread,
Jul 26, 2018, 4:17:34 PM7/26/18
to Blockly

I see that both divs (blocklyWidgetDiv and blocklyTooltipDiv) are rendered at the root of the document (in body actually) and that seems to be causing an issue with the fact that my div that I use in Blockly.inject() is not at the same level (body).

I've tried the CSS below, that's not doing the trick unfortunately.

I could move around the blocklyWidgetDiv and blocklyTooltipDiv divs with jQuery if that could help.

francis_...@smartpixel.tv

unread,
Jul 26, 2018, 4:49:57 PM7/26/18
to Blockly

Well, for now this seems to have solved the issue:

//Move those two Blockly generated divs inside the div used for the modal (at the root of it actually).

$('.blocklyWidgetDiv').prependTo('.modal-template');
$('.blocklyTooltipDiv').prependTo('.modal-template');

Rachel Fenichel

unread,
Jul 26, 2018, 7:27:44 PM7/26/18
to Blockly
Cool, I'm glad you have a fix.  If you find a general solution feel free to make a pull request.

Rachel
Reply all
Reply to author
Forward
0 new messages