mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-17 21:53:03 +05:30
#26: add a method to request panel height measurement from child components
This commit is contained in:
parent
a9efb9040a
commit
291a498f19
@ -11,6 +11,7 @@ export default class BaseAuthBody extends Component {
|
|||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
clearErrors: PropTypes.func.isRequired,
|
clearErrors: PropTypes.func.isRequired,
|
||||||
resolve: PropTypes.func.isRequired,
|
resolve: PropTypes.func.isRequired,
|
||||||
|
requestRedraw: PropTypes.func.isRequired,
|
||||||
auth: PropTypes.shape({
|
auth: PropTypes.shape({
|
||||||
error: PropTypes.string,
|
error: PropTypes.string,
|
||||||
scopes: PropTypes.array
|
scopes: PropTypes.array
|
||||||
|
@ -89,6 +89,7 @@ class PanelTransition extends Component {
|
|||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
user: userShape,
|
user: userShape,
|
||||||
|
requestRedraw: PropTypes.func,
|
||||||
clearErrors: PropTypes.func,
|
clearErrors: PropTypes.func,
|
||||||
resolve: PropTypes.func,
|
resolve: PropTypes.func,
|
||||||
reject: PropTypes.func
|
reject: PropTypes.func
|
||||||
@ -103,6 +104,7 @@ class PanelTransition extends Component {
|
|||||||
return {
|
return {
|
||||||
auth: this.props.auth,
|
auth: this.props.auth,
|
||||||
user: this.props.user,
|
user: this.props.user,
|
||||||
|
requestRedraw: () => this.setState({isHeightDirty: true}, () => this.setState({isHeightDirty: false})),
|
||||||
clearErrors: this.props.clearErrors,
|
clearErrors: this.props.clearErrors,
|
||||||
resolve: this.props.resolve,
|
resolve: this.props.resolve,
|
||||||
reject: this.props.reject
|
reject: this.props.reject
|
||||||
@ -196,7 +198,7 @@ class PanelTransition extends Component {
|
|||||||
</PanelHeader>
|
</PanelHeader>
|
||||||
<div style={contentHeight}>
|
<div style={contentHeight}>
|
||||||
<MeasureHeight
|
<MeasureHeight
|
||||||
state={this.props.auth.error}
|
state={this.shouldMeasureHeight()}
|
||||||
onMeasure={this.onUpdateContextHeight}
|
onMeasure={this.onUpdateContextHeight}
|
||||||
>
|
>
|
||||||
<PanelBody>
|
<PanelBody>
|
||||||
@ -307,6 +309,10 @@ class PanelTransition extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldMeasureHeight() {
|
||||||
|
return '' + this.props.auth.error + this.state.isHeightDirty;
|
||||||
|
}
|
||||||
|
|
||||||
getHeader({key, style, data}) {
|
getHeader({key, style, data}) {
|
||||||
const {Title, hasBackButton} = data;
|
const {Title, hasBackButton} = data;
|
||||||
const {transformSpring} = style;
|
const {transformSpring} = style;
|
||||||
@ -363,7 +369,7 @@ class PanelTransition extends Component {
|
|||||||
<MeasureHeight
|
<MeasureHeight
|
||||||
key={`body/${key}`}
|
key={`body/${key}`}
|
||||||
style={style}
|
style={style}
|
||||||
state={this.props.auth.error}
|
state={this.shouldMeasureHeight()}
|
||||||
onMeasure={(height) => this.onUpdateHeight(height, key)}
|
onMeasure={(height) => this.onUpdateHeight(height, key)}
|
||||||
>
|
>
|
||||||
{React.cloneElement(Body, {
|
{React.cloneElement(Body, {
|
||||||
|
@ -20,12 +20,6 @@ export default class ForgotPasswordBody extends BaseAuthBody {
|
|||||||
|
|
||||||
autoFocusField = this.state.isLoginEdit ? 'email' : null;
|
autoFocusField = this.state.isLoginEdit ? 'email' : null;
|
||||||
|
|
||||||
onClickEdit = () => {
|
|
||||||
this.setState({
|
|
||||||
isLoginEdit: true
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { user } = this.context;
|
const { user } = this.context;
|
||||||
const login = user.email || user.username || '';
|
const login = user.email || user.username || '';
|
||||||
@ -68,4 +62,11 @@ export default class ForgotPasswordBody extends BaseAuthBody {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClickEdit = () => {
|
||||||
|
this.setState({
|
||||||
|
isLoginEdit: true
|
||||||
|
});
|
||||||
|
this.context.requestRedraw();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user