#106: recalculate form height, after lang changed

This commit is contained in:
SleepWalker 2016-05-28 00:36:10 +03:00
parent 61534b069b
commit 0816e7a848
5 changed files with 18 additions and 7 deletions

View File

@ -316,7 +316,7 @@ class PanelTransition extends Component {
}
shouldMeasureHeight() {
return '' + this.props.auth.error + this.state.isHeightDirty;
return '' + this.props.auth.error + this.state.isHeightDirty + this.props.user.lang;
}
getHeader({key, style, data}) {

View File

@ -22,6 +22,7 @@ export default class ChangeEmail extends Component {
static propTypes = {
onChangeStep: PropTypes.func,
lang: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
stepForms: PropTypes.arrayOf((propValue, key, componentName, location, propFullName) => {
if (propValue.length !== 3) {
@ -161,7 +162,7 @@ export default class ChangeEmail extends Component {
<MeasureHeight
className={changeEmail.stepForm}
onMeasure={this.onStepMeasure(step)}
state={`${step}.${form.hasErrors()}`}
state={`${step}.${form.hasErrors()}.${this.props.lang}`}
key={step}
>
{this[`renderStep${step}`]({

View File

@ -52,8 +52,9 @@ export default class Form extends Component {
});
}
if (nextProps.form && nextProps.form !== this.props.form) {
throw new Error('The FormModel instance should not be changed during component lifetime');
if (nextProps.form && this.props.form && nextProps.form !== this.props.form) {
this.props.form.removeLoadingListener(this.onLoading);
nextProps.form.addLoadingListener(this.onLoading);
}
}

View File

@ -105,10 +105,16 @@ export default class FormModel {
}
beginLoading() {
this.handlers.forEach((fn) => fn(true));
this._isLoading = true;
this.notifyHandlers();
}
endLoading() {
this.handlers.forEach((fn) => fn(false));
this._isLoading = false;
this.notifyHandlers();
}
notifyHandlers() {
this.handlers.forEach((fn) => fn(this._isLoading));
}
}

View File

@ -9,6 +9,7 @@ class ChangeEmailPage extends Component {
static propTypes = {
email: PropTypes.string.isRequired,
lang: PropTypes.string.isRequired,
params: PropTypes.shape({
step: PropTypes.oneOf(['step1', 'step2', 'step3']),
code: PropTypes.string
@ -40,6 +41,7 @@ class ChangeEmailPage extends Component {
<ChangeEmail
onSubmit={this.onSubmit}
email={this.props.email}
lang={this.props.lang}
step={step.slice(-1) * 1 - 1}
onChangeStep={this.onChangeStep}
code={code}
@ -98,6 +100,7 @@ function handleErrors(repeatUrl) {
import { connect } from 'react-redux';
export default connect((state) => ({
email: state.user.email
email: state.user.email,
lang: state.user.lang
}), {
})(ChangeEmailPage);