git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 54d70439428e8fd11338aa37918eeab2dbd9f31a

search: wait until enter pressed

closes #492
Matt McKegg committed on 4/23/2017, 1:01:49 AM
Parent: ddbfc3b85f8f01ec6286faa76da2ab24762b3b5e

Files changed

modules/app/html/search.jschanged
modules/app/html/search.jsView
@@ -12,23 +12,19 @@
1212 exports.create = function (api) {
1313 return nest('app.html.search', function (setView) {
1414 var getProfileSuggestions = api.profile.async.suggest()
1515 var getChannelSuggestions = api.channel.async.suggest()
16- var searchTimer = null
1716 var searchBox = h('input.search', {
1817 type: 'search',
1918 placeholder: 'word, @key, #channel',
2019 'ev-suggestselect': (ev) => {
2120 setView(ev.detail.id)
2221 searchBox.value = ev.detail.id
2322 },
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') {
3025 doSearch()
26+ ev.preventDefault()
3127 }
3228 }
3329 })
3430
@@ -55,10 +51,8 @@
5551 } else if (value.trim()) {
5652 if (value.length > 2) {
5753 setView(`?${value.trim()}`)
5854 }
59- } else {
60- setView('/public')
6155 }
6256 }
6357 })
6458 }

Built with git-ssb-web