diff --git a/internal_packages/onboarding/lib/account-helpers.es6 b/internal_packages/onboarding/lib/account-helpers.es6
index 1b04803b2..deace9930 100644
--- a/internal_packages/onboarding/lib/account-helpers.es6
+++ b/internal_packages/onboarding/lib/account-helpers.es6
@@ -146,9 +146,9 @@ export function accountInfoWithIMAPAutocompletions(existingAccountInfo) {
const defaults = {
imap_host: template.imap_host,
imap_port: template.imap_port || 993,
- imap_username: usernameWithFormat(template.smtp_user_format),
+ imap_username: usernameWithFormat(template.imap_user_format),
imap_password: existingAccountInfo.password,
- smtp_host: template.imap_host,
+ smtp_host: template.smtp_host,
smtp_port: template.smtp_port || 587,
smtp_username: usernameWithFormat(template.smtp_user_format),
smtp_password: existingAccountInfo.password,
diff --git a/internal_packages/onboarding/lib/autofocus-container.jsx b/internal_packages/onboarding/lib/autofocus-container.jsx
deleted file mode 100644
index 60565af01..000000000
--- a/internal_packages/onboarding/lib/autofocus-container.jsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-
-export default class AutofocusContainer extends React.Component {
- static propTypes = {
- children: React.PropTypes.children,
- }
-
- componentDidMount() {
- this._applyFocus();
- }
-
- componentDidUpdate() {
- this._applyFocus();
- }
-
- _applyFocus() {
- const firstInput = ReactDOM.findDOMNode(this).querySelector('input');
- const anyInputFocused = document.activeElement && document.activeElement.nodeName === 'INPUT';
-
- if (firstInput && !anyInputFocused) {
- firstInput.focus();
- }
- }
-
- render() {
- return (
{this.props.children}
);
- }
-}
diff --git a/internal_packages/onboarding/lib/decorators/create-page-for-form.jsx b/internal_packages/onboarding/lib/decorators/create-page-for-form.jsx
index a96928336..5b8404769 100644
--- a/internal_packages/onboarding/lib/decorators/create-page-for-form.jsx
+++ b/internal_packages/onboarding/lib/decorators/create-page-for-form.jsx
@@ -1,9 +1,9 @@
import React from 'react';
+import ReactDOM from 'react-dom';
import {RetinaImg} from 'nylas-component-kit';
import {Actions} from 'nylas-exports';
import OnboardingActions from '../onboarding-actions';
-import AutofocusContainer from '../autofocus-container';
import {runAuthRequest} from '../account-helpers';
import FormErrorMessage from '../form-error-message';
import AccountTypes from '../account-types'
@@ -26,6 +26,34 @@ const CreatePageForForm = (FormComponent) => {
}, FormComponent.validateAccountInfo(this.props.accountInfo));
}
+ componentDidMount() {
+ this._applyFocus();
+ }
+
+ componentDidUpdate() {
+ this._applyFocus();
+ }
+
+ _applyFocus() {
+ const anyInputFocused = document.activeElement && document.activeElement.nodeName === 'INPUT';
+ if (anyInputFocused) {
+ return;
+ }
+
+ const inputs = Array.from(ReactDOM.findDOMNode(this).querySelectorAll('input'));
+ if (inputs.length === 0) {
+ return;
+ }
+
+ for (const input of inputs) {
+ if (input.value === '') {
+ input.focus();
+ return;
+ }
+ }
+ inputs[0].focus();
+ }
+
onFieldChange = (event) => {
const changes = {};
changes[event.target.id] = event.target.value;
@@ -135,17 +163,15 @@ const CreatePageForForm = (FormComponent) => {
message={errorMessage}
empty={FormComponent.subtitleLabel(AccountType)}
/>
-
-
-
+
Back
{this._renderButton()}
diff --git a/internal_packages/onboarding/lib/page-account-settings-imap.jsx b/internal_packages/onboarding/lib/page-account-settings-imap.jsx
index 83a5ab028..fcc816a4b 100644
--- a/internal_packages/onboarding/lib/page-account-settings-imap.jsx
+++ b/internal_packages/onboarding/lib/page-account-settings-imap.jsx
@@ -69,7 +69,7 @@ class AccountIMAPSettingsForm extends React.Component {
id={`ssl_required`}
className={(accountInfo.imap_host && errorFieldNames.includes(`ssl_required`)) ? 'error' : ''}
disabled={submitting}
- value={accountInfo[`ssl_required`] || ''}
+ checked={accountInfo[`ssl_required`] || false}
onKeyPress={onFieldKeyPress}
onChange={onFieldChange}
/>