Commit 54d70439428e8fd11338aa37918eeab2dbd9f31a
search: wait until enter pressed
closes #492Matt McKegg committed on 4/23/2017, 1:01:49 AM
Parent: ddbfc3b85f8f01ec6286faa76da2ab24762b3b5e
Files changed
modules/app/html/search.js | changed |
modules/app/html/search.js | ||
---|---|---|
@@ -12,23 +12,19 @@ | ||
12 | 12 | exports.create = function (api) { |
13 | 13 | return nest('app.html.search', function (setView) { |
14 | 14 | var getProfileSuggestions = api.profile.async.suggest() |
15 | 15 | var getChannelSuggestions = api.channel.async.suggest() |
16 | - var searchTimer = null | |
17 | 16 | var searchBox = h('input.search', { |
18 | 17 | type: 'search', |
19 | 18 | placeholder: 'word, @key, #channel', |
20 | 19 | 'ev-suggestselect': (ev) => { |
21 | 20 | setView(ev.detail.id) |
22 | 21 | searchBox.value = ev.detail.id |
23 | 22 | }, |
24 | - 'ev-input': (ev) => { | |
25 | - clearTimeout(searchTimer) | |
26 | - searchTimer = setTimeout(doSearch, 500) | |
27 | - }, | |
28 | - 'ev-focus': (ev) => { | |
29 | - if (searchBox.value) { | |
23 | + 'ev-keydown': (ev) => { | |
24 | + if (ev.code === 'Enter') { | |
30 | 25 | doSearch() |
26 | + ev.preventDefault() | |
31 | 27 | } |
32 | 28 | } |
33 | 29 | }) |
34 | 30 | |
@@ -55,10 +51,8 @@ | ||
55 | 51 | } else if (value.trim()) { |
56 | 52 | if (value.length > 2) { |
57 | 53 | setView(`?${value.trim()}`) |
58 | 54 | } |
59 | - } else { | |
60 | - setView('/public') | |
61 | 55 | } |
62 | 56 | } |
63 | 57 | }) |
64 | 58 | } |
Built with git-ssb-web