From 291a498f19d42ecfff18b7ae21a1356601069e8c Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Sun, 22 May 2016 16:07:51 +0300 Subject: [PATCH] #26: add a method to request panel height measurement from child components --- src/components/auth/BaseAuthBody.jsx | 1 + src/components/auth/PanelTransition.jsx | 10 ++++++++-- .../auth/forgotPassword/ForgotPasswordBody.jsx | 13 +++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/auth/BaseAuthBody.jsx b/src/components/auth/BaseAuthBody.jsx index 0548188..f2784ef 100644 --- a/src/components/auth/BaseAuthBody.jsx +++ b/src/components/auth/BaseAuthBody.jsx @@ -11,6 +11,7 @@ export default class BaseAuthBody extends Component { static contextTypes = { clearErrors: PropTypes.func.isRequired, resolve: PropTypes.func.isRequired, + requestRedraw: PropTypes.func.isRequired, auth: PropTypes.shape({ error: PropTypes.string, scopes: PropTypes.array diff --git a/src/components/auth/PanelTransition.jsx b/src/components/auth/PanelTransition.jsx index 0315cd8..484c50a 100644 --- a/src/components/auth/PanelTransition.jsx +++ b/src/components/auth/PanelTransition.jsx @@ -89,6 +89,7 @@ class PanelTransition extends Component { }) }), user: userShape, + requestRedraw: PropTypes.func, clearErrors: PropTypes.func, resolve: PropTypes.func, reject: PropTypes.func @@ -103,6 +104,7 @@ class PanelTransition extends Component { return { auth: this.props.auth, user: this.props.user, + requestRedraw: () => this.setState({isHeightDirty: true}, () => this.setState({isHeightDirty: false})), clearErrors: this.props.clearErrors, resolve: this.props.resolve, reject: this.props.reject @@ -196,7 +198,7 @@ class PanelTransition extends Component {
@@ -307,6 +309,10 @@ class PanelTransition extends Component { } } + shouldMeasureHeight() { + return '' + this.props.auth.error + this.state.isHeightDirty; + } + getHeader({key, style, data}) { const {Title, hasBackButton} = data; const {transformSpring} = style; @@ -363,7 +369,7 @@ class PanelTransition extends Component { this.onUpdateHeight(height, key)} > {React.cloneElement(Body, { diff --git a/src/components/auth/forgotPassword/ForgotPasswordBody.jsx b/src/components/auth/forgotPassword/ForgotPasswordBody.jsx index fae1612..810b177 100644 --- a/src/components/auth/forgotPassword/ForgotPasswordBody.jsx +++ b/src/components/auth/forgotPassword/ForgotPasswordBody.jsx @@ -20,12 +20,6 @@ export default class ForgotPasswordBody extends BaseAuthBody { autoFocusField = this.state.isLoginEdit ? 'email' : null; - onClickEdit = () => { - this.setState({ - isLoginEdit: true - }); - }; - render() { const { user } = this.context; const login = user.email || user.username || ''; @@ -68,4 +62,11 @@ export default class ForgotPasswordBody extends BaseAuthBody {
); } + + onClickEdit = () => { + this.setState({ + isLoginEdit: true + }); + this.context.requestRedraw(); + }; }