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

Commit

Permalink
Fix autocompelte selects part of URL after you typed it
Browse files Browse the repository at this point in the history
Auditors: @diracdeltas

Fix #5943
  • Loading branch information
bbondy committed Dec 6, 2016
1 parent c252087 commit b4ea7a3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/components/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ class UrlBar extends ImmutableComponent {
return
}
const suffixLen = this.props.locationValueSuffix.length
this.urlInput.value = this.locationValue + this.props.locationValueSuffix
const len = this.locationValue.length
this.urlInput.setSelectionRange(len, len + suffixLen)
}, 100)
if (suffixLen > 0 && this.urlInput.value !== this.locationValue + this.props.locationValueSuffix) {
this.urlInput.value = this.locationValue + this.props.locationValueSuffix
const len = this.locationValue.length
this.urlInput.setSelectionRange(len, len + suffixLen)
}
}, 10)
}

get activeFrame () {
Expand Down
38 changes: 38 additions & 0 deletions test/components/urlBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,44 @@ describe('urlBar tests', function () {
})
}

describe('typing speed', function () {
Brave.beforeAll(this)
before(function * () {
yield setup(this.app.client)
yield this.app.client.waitForExist(urlInput)
yield this.app.client.waitForElementFocus(urlInput)
yield this.app.client
.clearAppData({browserHistory: true})
.addSite({ location: 'https://brave.com', title: 'Brave' })
})

// OMG, Brad would hate this test!
const typingDelays = [0, 2, 11, 53, 101, 151, 251]
typingDelays.forEach((delay) => {
it(`delay of ${delay}ms/character fills correctly`, function * () {
const input = 'brave.com'
yield this.app.client
.keys(Brave.keys.ESCAPE)
.waitUntil(function () {
return this.getValue(urlInput).then((val) => val === '')
})
.waitForSelectedText('')
for (let i = 0; i < input.length; i++) {
yield this.app.client
.keys(input[i])
.pause(delay)
}
yield this.app.client
.waitForSelectedText('')
.waitUntil(function () {
return this.getValue(urlInput)
.then((val) => val === 'brave.com')
})
.keys(Brave.keys.ESCAPE)
})
})
})

describe('autocomplete', function () {
Brave.beforeEach(this)

Expand Down

0 comments on commit b4ea7a3

Please sign in to comment.