css - TreeSelect 在 Modal 中使用它并尝试打开它以查看它的元素时隐藏在后面
问题描述
我尝试使用 带有Modal的Ant Design TreeSelect 组件,但是当打开 TreeSelect 时,树的值隐藏在 Modal 后面。
我尝试使用更高的 z-index 值,但没有帮助!有任何想法吗?
import React from "react";
import ReactDOM from "react-dom";
import { version } from "antd";
import { TreeSelect } from "antd";
import {
Button,
ComposedModal,
ModalBody,
ModalFooter,
ModalHeader
} from "carbon-components-react";
import "antd/dist/antd.css";
import "./index.css";
const treeData = [
{
title: "Node1",
value: "0-0",
key: "0-0",
children: [
{
title: "Child Node1",
value: "0-0-1",
key: "0-0-1"
},
{
title: "Child Node2",
value: "0-0-2",
key: "0-0-2"
}
]
},
{
title: "Node2",
value: "0-1",
key: "0-1"
}
];
function treeSelectChange(e, value) {
console.log(e);
//e.preventDefault()
}
ReactDOM.render(
<div className="App">
<h1>antd version: {version}</h1>
{/* <p>
Please <b>fork</b> this sandbox to reproduce your issue.
</p> */}
<ComposedModal
open={true}
// onClose={(e) => this.closeRuleEditorModal(e) }
className=""
>
<ModalHeader title="Rule Editor" className="HeaderToolbar White" />
<ModalBody>
<TreeSelect
// className="on-front"
style={{
width: "100%"
}}
// value={element.Value}
dropdownStyle={{
maxHeight: 400,
overflow: "auto",
zIndex: 10000
// position: "absolute"
}}
treeData={treeData}
// placeholder={element.Name}
treeDefaultExpandAll
onChange={treeSelectChange}
/>
</ModalBody>
<ModalFooter>
<Button
kind="secondary"
size="small"
// onClick={(e) => this.closeRuleEditorModal(e) }
>
Cancel
</Button>
<Button
kind="primary"
id="btnSave"
size="small"
// onClick={() => this.fabricateCustomizedProject()}
>
Save
</Button>
</ModalFooter>
</ComposedModal>
</div>,
document.getElementById("root")
);
要重现问题,您也可以使用 https://codesandbox.io/s/antd-reproduction-template-ci559
更新
当我使用值为 10000 的 z-index 时,它对我有用(不知道为什么我必须设置如此高的值,这似乎是我用于其他组件的 CSS 之一-Modal- 在内部使用了一个大的 z-index) .
解决方案
推荐阅读
- python - Pyinstaller 安装成功但无法正常工作
- aws-lambda - 订阅 sns fifo 主题的 lambda 函数
- apache - 您无权访问请求的目录。没有索引文档或目录被读保护。xampp -phpmyadmin
- android - 使用 adb 命令从 youtube 剪辑 stat 以获取 nerds 信息
- pdf - Uipath 需要来自 abbyy 的许可证
- azure - 通过 CLI 启用分析存储时间
- html - CSS:如何根据背景颜色更改自定义滚动条颜色
- php - 选择另一个表值时回显表值
- javascript - 从 .json 文件返回 JSON 对象的函数
- kubernetes - Kubernetes Istio 配置与 Keycloak 用于 JWT 令牌验证