Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
prevent sync modal to force focus when switching inputs
Browse files Browse the repository at this point in the history
fix #11653
  • Loading branch information
cezaraugusto committed Jan 22, 2018
1 parent 5915913 commit 497d5a6
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions app/renderer/components/preferences/syncTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class SyncTab extends ImmutableComponent {
: getSetting(settings.SYNC_DEVICE_NAME, this.props.settings)
}

get deviceNameInputContent () {
deviceNameInputContent (hasAutoFocus = false) {
return <SettingItem>
<div className={css(styles.syncOverlayBody__label)} data-l10n-id='syncDeviceNameInput' />
<input className={css(
Expand All @@ -298,6 +298,7 @@ class SyncTab extends ImmutableComponent {
commonStyles.textbox__outlineable,
commonStyles.textbox__isSettings
)}
autoFocus={hasAutoFocus}
spellCheck='false'
ref={(node) => { this.deviceNameInput = node }}
placeholder={this.defaultDeviceName} />
Expand All @@ -306,7 +307,7 @@ class SyncTab extends ImmutableComponent {

get startOverlayContent () {
return <section className={css(styles.syncOverlayBody__formBottomMargin)}>
{this.deviceNameInputContent}
{this.deviceNameInputContent(true)}
</section>
}

Expand All @@ -329,12 +330,13 @@ class SyncTab extends ImmutableComponent {
styles.textArea__passphrase
)}
spellCheck='false'
autoFocus
ref={(node) => { this.passphraseInput = node }}
onChange={this.enableRestore}
/>
</div>
<div className={css(styles.syncOverlayBody__formBottomMargin)}>
{this.deviceNameInputContent}
{this.deviceNameInputContent()}
</div>
</section>
}
Expand Down Expand Up @@ -432,15 +434,6 @@ class SyncTab extends ImmutableComponent {
window.alert('Invalid input code; please try again or create a new profile.')
}

componentDidUpdate () {
if (!this.isSetup && this.props.syncStartOverlayVisible) {
this.deviceNameInput.focus()
}
if (!this.isSetup && this.props.syncAddOverlayVisible) {
this.passphraseInput.focus()
}
}

render () {
return <section data-test-id='syncContainer'>
{
Expand Down

0 comments on commit 497d5a6

Please sign in to comment.