mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-09 07:54:44 +00:00
Use new onClose prop to close sources when no result was selected
This commit is contained in:
parent
127cea6d9c
commit
d841616d0a
2 changed files with 3 additions and 12 deletions
|
|
@ -16,21 +16,11 @@ class DocumentSource extends ModalSource {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { entity } = this.props;
|
||||
const documentChooser = global.chooserUrls.documentChooser;
|
||||
const url = documentChooser;
|
||||
|
||||
$(document.body).on('hidden.bs.modal', this.onClose);
|
||||
|
||||
// TODO: wagtail should support passing params to this endpoint.
|
||||
if (entity) {
|
||||
// const entityData = entity.getData();
|
||||
// console.log(entityData);
|
||||
// if (entityData.title) {
|
||||
// url = url + `?q=${entityData.title}`
|
||||
// }
|
||||
}
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
window.ModalWorkflow({
|
||||
url,
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@ class ModalSource extends React.Component {
|
|||
}
|
||||
|
||||
onClose(e) {
|
||||
const { onComplete } = this.props;
|
||||
const { onClose } = this.props;
|
||||
e.preventDefault();
|
||||
|
||||
onComplete();
|
||||
onClose();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
@ -63,6 +63,7 @@ ModalSource.propTypes = {
|
|||
// eslint-disable-next-line
|
||||
entity: PropTypes.object,
|
||||
onComplete: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
ModalSource.defaultProps = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue