From bfe630f6f3a6c481e1fdd4895c18243af0939653 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Wed, 13 May 2015 17:13:51 +0100 Subject: Search completion; implement timer. With suggested completions appearing in the vomnibar, the meaning of 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 to do), we block 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. --- pages/vomnibar.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) 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") + # 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() + # 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: => -- cgit v1.2.3