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

Commit

Permalink
Merge pull request #8510 from kumarrishav/autoFillautoFocusFix
Browse files Browse the repository at this point in the history
Autofill should focus on first entry Fix #8280
  • Loading branch information
bsclifton committed May 3, 2017
2 parents de7e8a8 + d1f502a commit 612350d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
6 changes: 4 additions & 2 deletions app/renderer/components/autofill/autofillAddressPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class AutofillAddressPanel extends ImmutableComponent {
!currentDetail.get('phone') && !currentDetail.get('email')) return true
return false
}

componentDidMount () {
this.nameOnAddress.focus()
}
render () {
return <Dialog onHide={this.props.onHide} testId='autofillAddressPanel' isClickDismiss>
<CommonFormLarge onClick={this.onClick}>
Expand All @@ -136,7 +138,7 @@ class AutofillAddressPanel extends ImmutableComponent {
)}
data-test-id='nameOnAddress'
spellCheck='false' onKeyDown={this.onKeyDown} onChange={this.onNameChange}
value={this.props.currentDetail.get('name')}
value={this.props.currentDetail.get('name') || ''}
ref={(nameOnAddress) => { this.nameOnAddress = nameOnAddress }} />
<div className={css(commonFormStyles.input__marginRow)}>
<CommonFormTextbox
Expand Down
7 changes: 6 additions & 1 deletion app/renderer/components/autofill/autofillCreditCardPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class AutofillCreditCardPanel extends ImmutableComponent {
if (!currentDetail.get('name') && !currentDetail.get('card')) return true
return false
}
componentDidMount () {
this.nameOnCard.focus()
}
render () {
var ExpMonth = []
for (let i = 1; i <= 12; ++i) {
Expand Down Expand Up @@ -112,17 +115,19 @@ class AutofillCreditCardPanel extends ImmutableComponent {
commonFormStyles.input__box,
styles.input
)}
data-test-id='creditCardName'
spellCheck='false'
onKeyDown={this.onKeyDown}
onChange={this.onNameChange}
value={this.props.currentDetail.get('name')}
value={this.props.currentDetail.get('name') || ''}
ref={(nameOnCard) => { this.nameOnCard = nameOnCard }}
/>
</div>
<div data-test-id='creditCardNumberWrapper'
className={css(commonFormStyles.input__marginRow)
}>
<CommonFormTextbox
data-test-id='creditCardNumber'
spellCheck='false'
onKeyDown={this.onKeyDown}
onChange={this.onCardChange}
Expand Down
16 changes: 8 additions & 8 deletions test/contents/autofillTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Autofill', function () {
.click(addAddressButton)
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(autofillAddressPanel)
.click('[data-test-id="nameOnAddress"]')
.waitForElementFocus('[data-test-id="nameOnAddress"]')
.keys(name)
.click('[data-test-id="organization"]')
.keys(organization)
Expand Down Expand Up @@ -189,9 +189,9 @@ describe('Autofill', function () {
.click(addCreditCardButton)
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(autofillCreditCardPanel)
.click('[data-test-id="creditCardNameWrapper"]')
.waitForElementFocus('[data-test-id="creditCardName"]')
.keys(cardName)
.click('[data-test-id="creditCardNumberWrapper"]')
.click('[data-test-id="creditCardNumber"]')
.keys(cardNumber)
.selectByValue('[data-test-id="expMonthSelect"]', expMonth < 10 ? '0' + expMonth.toString() : expMonth.toString())
.selectByValue('[data-test-id="expYearSelect"]', expYear.toString())
Expand Down Expand Up @@ -252,10 +252,10 @@ describe('Autofill', function () {
.click('[data-test-id="EditCreditCard"]')
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(autofillCreditCardPanel)
.click('[data-test-id="creditCardNameWrapper"]')
.waitForElementFocus('[data-test-id="creditCardName"]')
.keys(Brave.keys.END)
.keys('123')
.click('[data-test-id="creditCardNumberWrapper"]')
.click('[data-test-id="creditCardNumber"]')
.keys(Brave.keys.END)
.keys('123')
.selectByValue('[data-test-id="expMonthSelect"]', (expMonth + 1).toString())
Expand Down Expand Up @@ -311,7 +311,7 @@ describe('Autofill', function () {
.click(addAddressButton)
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(autofillAddressPanel)
.click('[data-test-id="nameOnAddress"]')
.waitForElementFocus('[data-test-id="nameOnAddress"]')
.keys(name)
.click('[data-test-id="organization"]')
.keys(organization)
Expand Down Expand Up @@ -341,9 +341,9 @@ describe('Autofill', function () {
.click(addCreditCardButton)
.windowByUrl(Brave.browserWindowUrl)
.waitForVisible(autofillCreditCardPanel)
.click('[data-test-id="creditCardNameWrapper"]')
.waitForElementFocus('[data-test-id="creditCardName"]')
.keys(cardName)
.click('[data-test-id="creditCardNumberWrapper"]')
.click('[data-test-id="creditCardNumber"]')
.keys(cardNumber)
.selectByValue('[data-test-id="expMonthSelect"]', expMonth < 10 ? '0' + expMonth.toString() : expMonth.toString())
.selectByValue('[data-test-id="expYearSelect"]', expYear.toString())
Expand Down

0 comments on commit 612350d

Please sign in to comment.