Skip to content

Commit

Permalink
add lastVisible
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Apr 28, 2015
1 parent 1855d75 commit 734e076
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ var Dialog = React.createClass({

componentDidMount() {
this.componentDidUpdate();
if (this.props.visible) {
React.findDOMNode(this.refs.dialog).focus();
}
},

componentDidUpdate() {
var props = this.props;
if (props.visible) {
this.align();
this.monitorWindowResize();
if (!this.lastVisible) {
React.findDOMNode(this.refs.dialog).focus();
}
} else {
this.unMonitorWindowResize();
}
this.lastVisible = props.visible;
},

componentWillUnmount() {
Expand Down Expand Up @@ -90,7 +91,7 @@ var Dialog = React.createClass({
}
return (<div className={className.join(' ')}>
<div {...maskProps} className={prefixClsFn(prefixCls, 'mask')}/>
<div className={[prefixClsFn(prefixCls,''), props.className].join(' ')} tabIndex="0" role="dialog" ref='dialog' style={style}>
<div className={[prefixClsFn(prefixCls, ''), props.className].join(' ')} tabIndex="0" role="dialog" ref='dialog' style={style}>
<div className={prefixClsFn(prefixCls, 'content')}>
<div className={prefixClsFn(prefixCls, 'header')}>
{closable ?
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-dialog",
"version": "4.0.2",
"version": "4.0.3",
"description": "dialog ui component for react",
"keywords": [
"react",
Expand Down

0 comments on commit 734e076

Please sign in to comment.