diff options
| author | Stephen Blott | 2015-05-13 17:13:51 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-13 17:17:44 +0100 |
| commit | bfe630f6f3a6c481e1fdd4895c18243af0939653 (patch) | |
| tree | 792d07b2bfdb52ef3029f5d17f5e7482a5533ae4 | |
| parent | c3d399f9467e07733340a56ca1f71b61bedad1f9 (diff) | |
| download | vimium-bfe630f6f3a6c481e1fdd4895c18243af0939653.tar.bz2 | |
Search completion; implement <Enter> timer.
With suggested completions appearing in the vomnibar, the meaning of
<Enter> can change when the completion list is updated, which happens
asynchronously. The user can end up selecting something they didn't
intend to ... which is bad.
This implements a temporary fix. When the completion list updates (and
the update might affect what the user expects <Enter> to do), we block
<Enter> for a short time (250ms). That's pretty bad too.
These UX issues around search completion are proving difficult to get
right. I will open an issue to discuss them soon.
| -rw-r--r-- | pages/vomnibar.coffee | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index b168abf0..a96a3b4f 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -69,6 +69,7 @@ class VomnibarUI @completions = [] @previousAutoSelect = null @previousInputValue = null + @lastUpdateTime = null @suppressedLeadingKeyword = null @selection = @initialSelectionValue @keywords = [] @@ -195,8 +196,13 @@ class VomnibarUI @selection = @completions.length - 1 if @selection < @initialSelectionValue @updateSelection() else if (action == "enter") + # <Enter> immediately after new suggestions have been posted is ignored. It's all too common that the + # user gets results they weren't intending. + return if @lastUpdateTime? and new Date() - @lastUpdateTime < 250 and @inputContainsASelectionRange() + @lastUpdateTime = null if @selection == -1 query = @input.value.trim() + # <Enter> on an empty query is a no-op. return unless 0 < query.length # If the user types something and hits enter without selecting a completion from the list, then: # - If a search URL has been provided, then use it. This is custom search engine request. @@ -241,6 +247,8 @@ class VomnibarUI true onKeypress: (event) => + # The user is typing. They know what they're doing. + @lastUpdateTime = null # Handle typing together with prompted text. unless event.altKey or event.ctrlKey or event.metaKey if @inputContainsASelectionRange() @@ -284,6 +292,7 @@ class VomnibarUI @previousAutoSelect = null if @completions[0]?.autoSelect and @completions[0]?.forceAutoSelect @updateSelection() @addPromptedText() + @lastUpdateTime = new Date() callback?() updateOnInput: => |
