Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal open problem #3729

Closed
SallyOne opened this issue Nov 3, 2016 · 6 comments · Fixed by #3736
Closed

Modal open problem #3729

SallyOne opened this issue Nov 3, 2016 · 6 comments · Fixed by #3736
Assignees

Comments

@SallyOne
Copy link

SallyOne commented Nov 3, 2016

Modal 关闭打开后会带上一次的样式,比如搭配transfer,如果勾中了checkbox,那么Modal关闭后再打开checkbox还是勾中的。有什么办法解决这个问题????

@benjycui
Copy link
Contributor

benjycui commented Nov 4, 2016

重置 Modal 内组件的状态、属性。

@benjycui benjycui closed this as completed Nov 4, 2016
@SallyOne
Copy link
Author

SallyOne commented Nov 4, 2016

transfer 里的checkbox全选怎么重置?文档里没有?

@benjycui
Copy link
Contributor

benjycui commented Nov 4, 2016

Transfer 还是要增加 selectedKeys 受控属性。。

@yesmeck
Copy link
Member

yesmeck commented Nov 6, 2016

感觉这里还是自己把 Model unmount 掉来处理好点吧?

@benjycui
Copy link
Contributor

benjycui commented Nov 7, 2016

Modal[visible] 及其它组件的 visible 属性的设计就是为了重用,直接 unmount 有点违背初衷了。

@harunme
Copy link

harunme commented Jul 21, 2017

antd is amazing,thanks

import React, { PureComponent, Component } from 'react';
import { Modal as AntModal } from 'antd';
import PropTypes from 'prop-types';

class Modal extends (PureComponent || Component) {
constructor(props) {
super(props);
this.state = { renderChild: true };
}

componentWillReceiveProps(nextProps) {
const { destroyInvisibleModal = false } = this.props;
if (destroyInvisibleModal) {
if (nextProps.visible)
this.setState({ renderChild: true });
else
this.setState({ renderChild: false });
}
}

render() {
return (
this.state.renderChild ? <AntModal {...this.props} /> : null
);
}
}

Modal.propTypes = {
// destroy invisible Modal, default false
destroyInvisibleModal: PropTypes.bool
};

export default Modal;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants