Skip to content

Commit 35ea201

Browse files
committed
[fixed] Accidental breaking change in Modal trigger
fixes react-bootstrap#929
1 parent f132921 commit 35ea201

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

src/Modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ const Modal = React.createClass({
449449
<ModalMarkup {...props}>{this.props.children}</ModalMarkup>
450450
);
451451
// I can't think of another way to not break back compat while defaulting container
452-
if ( show != null ){
452+
if ( !this.props.__isUsedInModalTrigger && show != null ){
453453
return (
454454
<Portal container={props.container} >
455455
{ show && modal }

src/ModalTrigger.js

+10-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import deprecationWarning from './utils/deprecationWarning';
44

55
import createChainedFunction from './utils/createChainedFunction';
66
import createContextWrapper from './utils/createContextWrapper';
7+
import { OverlayMixin } from './OverlayMixin';
78

89
function createHideDepreciationWrapper(hide){
910
return function(...args){
@@ -16,6 +17,8 @@ function createHideDepreciationWrapper(hide){
1617

1718
const ModalTrigger = React.createClass({
1819

20+
mixins: [ OverlayMixin ],
21+
1922
propTypes: {
2023
modal: React.PropTypes.node.isRequired,
2124
/**
@@ -28,6 +31,7 @@ const ModalTrigger = React.createClass({
2831
onMouseOver: React.PropTypes.func
2932
},
3033

34+
3135
getInitialState() {
3236
return {
3337
isOverlayShown: false
@@ -52,31 +56,19 @@ const ModalTrigger = React.createClass({
5256
});
5357
},
5458

55-
componentDidMount(){
56-
this._overlay = document.createElement('div');
57-
React.render(this.getOverlay(), this._overlay);
58-
},
59-
60-
componentWillUnmount() {
61-
React.unmountComponentAtNode(this._overlay);
62-
this._overlay = null;
63-
clearTimeout(this._hoverDelay);
64-
},
65-
66-
componentDidUpdate(){
67-
React.render(this.getOverlay(), this._overlay);
68-
},
69-
70-
getOverlay() {
59+
renderOverlay() {
7160
let modal = this.props.modal;
7261

62+
if (!this.state.isOverlayShown) {
63+
return <span />;
64+
}
65+
7366
return cloneElement(
7467
modal,
7568
{
76-
show: this.state.isOverlayShown,
7769
onHide: this.hide,
7870
onRequestHide: createHideDepreciationWrapper(this.hide),
79-
container: modal.props.container || this.props.container
71+
__isUsedInModalTrigger: true
8072
}
8173
);
8274
},

0 commit comments

Comments
 (0)