mirror of https://github.com/zulip/zulip.git
Support smartSpaceBar option in typeahead.
If you set the option, then hitting space will select the current suggestion and allow you to keep typing. If you don't set it, then it's the old behavior where space allows you to continue typing without acknowledging your selection. (imported from commit 8125a322e5a748ac7716361d66fca18c56d5766e)
This commit is contained in:
parent
cd71840942
commit
fcb3999996
|
@ -1841,6 +1841,19 @@
|
||||||
return this.hide()
|
return this.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
, select_and_continue: function () {
|
||||||
|
// We don't call updater() because it potentially has side-effects.
|
||||||
|
// This does mean that smartSpaceBar can't be used in cases where the
|
||||||
|
// item values are transformed by updater(). It's generally imprudent
|
||||||
|
// to do transformations in updater(), so this should be a
|
||||||
|
// non-issue for most users.
|
||||||
|
var val = this.$menu.find('.active').data('typeahead-value')
|
||||||
|
this.$element
|
||||||
|
.val(val + ' ')
|
||||||
|
.change()
|
||||||
|
return this.hide()
|
||||||
|
}
|
||||||
|
|
||||||
, updater: function (item) {
|
, updater: function (item) {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
@ -2027,6 +2040,16 @@
|
||||||
this.select()
|
this.select()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 32: // space
|
||||||
|
if (this.options.smartSpaceBar) {
|
||||||
|
if (!this.shown) return
|
||||||
|
this.select_and_continue()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.lookup()
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
case 27: // escape
|
case 27: // escape
|
||||||
if (!this.shown) return
|
if (!this.shown) return
|
||||||
this.hide()
|
this.hide()
|
||||||
|
|
Loading…
Reference in New Issue