How to handle quot;outsidequot; click on Dialog (Modal) with material-ui(如何处理“外点击 Dialog (Modal) with material-ui)
问题描述
在框外单击时我的框关闭,使我丢失所有输入.我希望我的盒子只有在点击取消按钮时才关闭.我不确定是什么使它在外面点击时关闭.有什么帮助吗?
My box closes when clicking outside of the box making me lose all the input. I want my box to close only when clicking on the cancel button. I am not sure what is making it close when clicking outside. Any help?
我正在使用@material-ui/core
I am using @material-ui/core
_close() {
DeviceCreationActions.close();
}
render() {
const actions = [
<Button
id="device-create-dialog-close"
key="device-create-dialog-close"
onClick={this._close}
>
{this.context.intl.formatMessage({id: 'Cancel'})}
</Button>
];
if (0 < this.state.stepIndex) {
actions.push(<Button
id="device-create-dialog-back"
key="device-create-dialog-back"
onClick={this._previousStep.bind(this)}
>
{this.context.intl.formatMessage({id: 'Back'})}
</Button>
);
}
if (
(1 >= this.state.stepIndex && 0 < this.state['formStep' + this.state.stepIndex].length) ||
(0 < this.state.stepIndex)
) {
actions.push(<Button
id="device-create-dialog-next"
key="device-create-dialog-next"
onClick={2 === this.state.stepIndex ? this._save.bind(this) : this._nextStep.bind(this)}
>
{this.context.intl.formatMessage({id: 2 === this.state.stepIndex ? 'Create' : 'Next'})}
</Button>
);
}
推荐答案
我想你需要的是 disableBackdropClick 传递给
I think what you need is disableBackdropClick passed down to <Modal /> component
<Modal disableBackdropClick />
您还可以使用 disableEscapeKeyDown prop
You can also disable close Dialog on Esc key press with disableEscapeKeyDown prop
这篇关于如何处理“外"点击 Dialog (Modal) with material-ui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何处理“外"点击 Dialog (Modal) with material-ui
基础教程推荐
- 如何在特定日期之前获取消息? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
