From 94217ff5194a25aa1d9c16450162d1865205d8ad Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Mon, 1 Jan 2018 19:00:38 +0200 Subject: [PATCH] 01.01.2018 --- src/components/auth/PanelTransition.js | 13 ++++++++++++- .../auth/forgotPassword/ForgotPasswordBody.js | 7 +++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/auth/PanelTransition.js b/src/components/auth/PanelTransition.js index 7bca9f2..edc67f3 100644 --- a/src/components/auth/PanelTransition.js +++ b/src/components/auth/PanelTransition.js @@ -113,7 +113,18 @@ class PanelTransition extends Component { return { auth: this.props.auth, user: this.props.user, - requestRedraw: () => this.setState({isHeightDirty: true}, () => this.setState({isHeightDirty: false})), + requestRedraw: () => + new Promise((resolve) => + this.setState( + {isHeightDirty: true}, + () => { + this.setState({isHeightDirty: false}); + + // wait till transition end + setTimeout(resolve, 200); + } + ) + ), clearErrors: this.props.clearErrors, resolve: this.props.resolve, reject: this.props.reject diff --git a/src/components/auth/forgotPassword/ForgotPasswordBody.js b/src/components/auth/forgotPassword/ForgotPasswordBody.js index 2419ce6..d13fb75 100644 --- a/src/components/auth/forgotPassword/ForgotPasswordBody.js +++ b/src/components/auth/forgotPassword/ForgotPasswordBody.js @@ -82,9 +82,8 @@ export default class ForgotPasswordBody extends BaseAuthBody { this.setState({ isLoginEdit: true }); - this.context.requestRedraw(); - // TODO: requestRedraw должен возвращать promise, по которому нужно ставить фокус на поле - // иначе же, если фокус ставить сразу, то форма скачет - setTimeout(() => {this.form.focus('login');}, 300); + + this.context.requestRedraw() + .then(() => this.form.focus('login')); }; }