Skip to content

Commit

Permalink
[fixed] Accidental breaking change in Modal trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Jul 1, 2015
1 parent f132921 commit 35ea201
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ const Modal = React.createClass({
<ModalMarkup {...props}>{this.props.children}</ModalMarkup>
);
// I can't think of another way to not break back compat while defaulting container
if ( show != null ){
if ( !this.props.__isUsedInModalTrigger && show != null ){
return (
<Portal container={props.container} >
{ show && modal }
Expand Down
28 changes: 10 additions & 18 deletions src/ModalTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import deprecationWarning from './utils/deprecationWarning';

import createChainedFunction from './utils/createChainedFunction';
import createContextWrapper from './utils/createContextWrapper';
import { OverlayMixin } from './OverlayMixin';

function createHideDepreciationWrapper(hide){
return function(...args){
Expand All @@ -16,6 +17,8 @@ function createHideDepreciationWrapper(hide){

const ModalTrigger = React.createClass({

mixins: [ OverlayMixin ],

propTypes: {
modal: React.PropTypes.node.isRequired,
/**
Expand All @@ -28,6 +31,7 @@ const ModalTrigger = React.createClass({
onMouseOver: React.PropTypes.func
},


getInitialState() {
return {
isOverlayShown: false
Expand All @@ -52,31 +56,19 @@ const ModalTrigger = React.createClass({
});
},

componentDidMount(){
this._overlay = document.createElement('div');
React.render(this.getOverlay(), this._overlay);
},

componentWillUnmount() {
React.unmountComponentAtNode(this._overlay);
this._overlay = null;
clearTimeout(this._hoverDelay);
},

componentDidUpdate(){
React.render(this.getOverlay(), this._overlay);
},

getOverlay() {
renderOverlay() {
let modal = this.props.modal;

if (!this.state.isOverlayShown) {
return <span />;
}

return cloneElement(
modal,
{
show: this.state.isOverlayShown,
onHide: this.hide,
onRequestHide: createHideDepreciationWrapper(this.hide),
container: modal.props.container || this.props.container
__isUsedInModalTrigger: true
}
);
},
Expand Down

0 comments on commit 35ea201

Please sign in to comment.