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

UrlBar and suggestion improvements #5046

Merged
merged 1 commit into from
Oct 23, 2016
Merged

UrlBar and suggestion improvements #5046

merged 1 commit into from
Oct 23, 2016

Conversation

Sh1d0w
Copy link

@Sh1d0w Sh1d0w commented Oct 22, 2016

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Fixes #5025
FIxes #4941
Fixes #5043
Fixes #4663

cc @bbondy @diracdeltas

@@ -204,8 +197,13 @@ class UrlBar extends ImmutableComponent {
case KeyCodes.BACKSPACE:
this.hideAutoComplete()
break
// Do not trigger rendering of suggestions if you are pressing alt or shift
case KeyCodes.ALT:
case KeyCodes.SHIFT:
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this also include most other modifier keys?

Copy link
Author

Choose a reason for hiding this comment

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

I have added two more. If you think I missed some, please let me know I will add :)

@@ -88,20 +87,5 @@ describe('urlBar', function () {
.then((val) => val === 'aboutx')
})
})

it('it does not change input after focus until keydown', function * () {
Copy link
Member

Choose a reason for hiding this comment

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

please change this test to test that focus doesn't bring up any suggestions, thanks

@@ -281,6 +275,9 @@ class UrlBar extends ImmutableComponent {
this.clearSearchEngine()
this.detectSearchEngine(e.target.value)
this.keyPressed = false
if (e.target.value.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

just to be paranoid-safe, check that e.target.value exists before calling e.target.value.length

@@ -38,16 +38,14 @@ class UrlBar extends ImmutableComponent {
this.onFocus = this.onFocus.bind(this)
this.onBlur = this.onBlur.bind(this)
this.onKeyDown = this.onKeyDown.bind(this)
this.onCut = this.onCut.bind(this)
this.onKeyUp = this.onKeyUp.bind(this)
this.onChange = this.onChange.bind(this)
Copy link
Member

Choose a reason for hiding this comment

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

this is minor, but the s/onChange/onKeyUp change should be kept because it helps readability

@diracdeltas
Copy link
Member

diracdeltas commented Oct 22, 2016

this seems to have introduced a bug where the URL bar suggestions appear and flicker when the tab is switched. str:

  1. open tab, go to bing.com
  2. open tab, go to twitter.com
  3. switch back to tab 1, autosuggest renders automatically
  4. switch to tab 2, autosuggest renders there as well

probably because shouldRenderUrlBarSuggestions needs to check that the urlbar is active

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 22, 2016

@diracdeltas Yes I know I am preparing commit atm. Will let you know when it is ready for review. Thanks

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 22, 2016

@diracdeltas All fixed now, added tests as well :)

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 22, 2016

Updated the PR with the fix for #5043 and closed the other PR so all is in one place.

.ipcSend('shortcut-focus-url')
.getValue(urlInput).then((val) => assert(val === 'https://brave.com/'))
.keys('\uE015')
it('does not show suggestions on focus', function * () {
Copy link
Member

Choose a reason for hiding this comment

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

i think you want to type some letters before focusing, otherwise it wouldn't show suggestions anyway

Copy link
Author

Choose a reason for hiding this comment

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

Ah, I am so sleepy. Fixed, thanks

@Sh1d0w Sh1d0w changed the title CTRL+L should not render suggestions UrlBar and suggestion improvements Oct 22, 2016
@@ -89,7 +89,9 @@ describe('urlBar', function () {
})

it('does not show suggestions on focus', function * () {
yield this.app.client.ipcSend('shortcut-focus-url')
yield this.app.client
.keys('brave')
Copy link
Member

Choose a reason for hiding this comment

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

just to be sure this actually brings up suggestions, please add

.waitUntil(function () {
            return this.isExisting(urlBarSuggestions).then((exists) => exists === true)

here

Copy link
Author

Choose a reason for hiding this comment

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

Done

@diracdeltas
Copy link
Member

otherwise lgtm once this is rebased, assuming travis mostly passes. thanks!

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 22, 2016

@diracdeltas rebased, no worries.

The Url bar feels so fast and slick now, I've built a custom package for me with it so I can test it :)

@diracdeltas
Copy link
Member

@Sh1d0w i think there are some travis test failures related to this change. specifically 14-17 in https://travis-ci.org/brave/browser-laptop/builds/169690847

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 23, 2016

@diracdeltas Travis constanlty fails different tests. See for example here https://travis-ci.org/brave/browser-laptop/builds/169702712 which is from this PR (not related to any navbar changes) #5056

If I execute the tests locally everything passes, also if I manually test the failed tests (for example typing the first char) it works just ok.

@diracdeltas
Copy link
Member

@Sh1d0w yeah, travis is not reliable yet so i mostly look at tests which seem like they may be related. in this case npm run test -- --grep='urlbarSuggestions' and npm run test -- --grep='navigationBar' do not pass locally for me. could plausibly be unrelated to this PR, in which case i'll fix it later.

@diracdeltas
Copy link
Member

actually all those failures from this PR exist in https://travis-ci.org/brave/browser-laptop/builds/169696262 as well except for:

  14) navigationBar typing "before all" hook: _callee46:
     Error: element (.urlBarSuggestions li) still not existing after 5000ms

so i think that one is probably related, but the others aren't.

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 23, 2016

@diracdeltas I will look into this and will get back to you with my findings. Thanks

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 23, 2016

@diracdeltas Actually the test for typing a single character is failing and thats why 14) is failing as well. Idk what's the case there since if you run locally my branch you can see that if you type a single character in the URL bar the suggestions appear.

I guess it is timeout issue since it only fails in the test but I could use some help here if you don't mind :)

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 23, 2016

@diracdeltas The bug is fixed this test should pass now. Let me know if you find any other issue.

@Sh1d0w
Copy link
Author

Sh1d0w commented Oct 23, 2016

@diracdeltas @bbondy Because of the changes made in #3049 most of the tests regarding UrlBar Suggestions were failing because now the order of history entries have changed.

I fixed those tests in my PR, but please make sure in future when merging stuff that tests pass, because as you can see then we have trouble in the following PR's

Thanks guys.

@diracdeltas
Copy link
Member

LGTM, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants