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

Autofill should focus on first entry Fix #8280 #8510

Merged
merged 2 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') || ''}
Copy link
Contributor Author

@kumarrishav kumarrishav Apr 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added default value as {this.props.currentDetail.get('name') || ''} to avoid the warning (because of react 15 upgrade).
warning.js?8a56:36
Warning: AutofillAddressPanel is changing an uncontrolled input of type undefined to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlled-components.

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') || ''}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

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