简体   繁体   English

在 Material-UI 模式中无法编辑 Blocklys Textblock 输入字段

[英]Blocklys Textblock input fields can not be edited when in a Material-UI Modal

I only found https://groups.google.com/g/blockly/c/SDUosMpAFAk to my problem, but it has no answers that could help me, so I created a Codesandbox to reproduce the behavior.我只找到https://groups.google.com/g/blockly/c/SDUosMpAFAk来解决我的问题,但它没有可以帮助我的答案,所以我创建了一个 Codesandbox 来重现该行为。

https://codesandbox.io/s/gallant-galois-bqjjb https://codesandbox.io/s/gallant-galois-bqjjb

The button in the Sandbox will open a modal with a Blockly Canvas in it.沙盒中的按钮将打开一个带有 Blockly Canvas 的模式。 Trying to write something in the "text"- or "math_number"-Block does not work, and when you close the modal, with an outside click, some artifacts are staying.尝试在“文本”或“math_number”块中写一些东西是行不通的,当你关闭模态时,用外部点击,一些工件会留下来。

I would be glad if someone can help me out with this.如果有人能帮我解决这个问题,我会很高兴。

You can set the property disableEnforceFocus to true , and that will solve the problem for the input text/number blocks.您可以将属性disableEnforceFocus设置为true ,这将解决输入文本/数字块的问题。 However the problem persists for blocks using selection elements (eg logic_compare , math_arithmetic ).然而,对于使用选择元素(例如logic_comparemath_arithmetic )的块,问题仍然存在。

<Modal
       ...
        disableEnforceFocus
>
....
</Modal>

Here you can see an example showing the above behaviour在这里您可以看到一个显示上述行为的示例

https://codesandbox.io/s/lucid-booth-w18h4?file=/src/App.js https://codesandbox.io/s/lucid-booth-w18h4?file=/src/App.js

I found the source of the issue with multiple choice input blocks: z-index.我找到了多项选择输入块的问题根源:z-index。

After I changed the z-index for the blocklyDropDownDiv the problem was gone.在我更改了blocklyDropDownDiv的 z-index 后,问题就消失了。

Add the following CSS class and that's it 😀添加以下 CSS 类就可以了 😀

.blocklyDropDownDiv {
    z-index: 5000;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM