From 54cfe7e98149141e04f04c71342ea8d7e2bc48ed Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 16 Jun 2019 15:24:20 -0700 Subject: [PATCH] Clear email field on send --- .../components/auth/ForgotPasswordContainer.tsx | 15 ++++++++++++--- .../scripts/components/forms/OpenInputField.tsx | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/resources/scripts/components/auth/ForgotPasswordContainer.tsx b/resources/scripts/components/auth/ForgotPasswordContainer.tsx index 89e811ed6..4982fdbea 100644 --- a/resources/scripts/components/auth/ForgotPasswordContainer.tsx +++ b/resources/scripts/components/auth/ForgotPasswordContainer.tsx @@ -18,6 +18,8 @@ type State = Readonly<{ }>; class ForgotPasswordContainer extends React.PureComponent { + emailField = React.createRef(); + state: State = { email: '', isSubmitting: false, @@ -33,9 +35,15 @@ class ForgotPasswordContainer extends React.PureComponent { this.setState({ isSubmitting: true }, () => { this.props.clearAllFlashMessages(); requestPasswordResetEmail(this.state.email) - .then(response => this.props.pushFlashMessage({ - type: 'success', title: 'Success', message: response, - })) + .then(response => { + if (this.emailField.current) { + this.emailField.current.value = ''; + } + + this.props.pushFlashMessage({ + type: 'success', title: 'Success', message: response, + }); + }) .catch(error => { console.error(error); this.props.pushFlashMessage({ @@ -54,6 +62,7 @@ class ForgotPasswordContainer extends React.PureComponent {
& { description?: string; }; -export default ({ className, description, onChange, label, ...props }: Props) => { +export default React.forwardRef(({ className, description, onChange, label, ...props }, ref) => { const [ value, setValue ] = React.useState(''); const classes = classNames('input open-label', { @@ -16,6 +16,7 @@ export default ({ className, description, onChange, label, ...props }: Props) => return (
{ setValue(e.target.value); @@ -33,4 +34,4 @@ export default ({ className, description, onChange, label, ...props }: Props) => }
); -}; +});