mirror of https://github.com/zulip/zulip.git
Support naturalSearch option in typeahead.
The naturalSearch option immediately updates the search box with the underlying value of a search suggestion when the user moves to it. (imported from commit ad5cb5c2591ef4f71a6d648c8839f288cc125cf7)
This commit is contained in:
parent
49619a85dc
commit
dc85fa7cf2
|
@ -1826,6 +1826,9 @@
|
|||
this.source = this.options.source
|
||||
this.shown = false
|
||||
this.dropup = this.options.dropup
|
||||
// The naturalSearch option causes arrow keys to immediately
|
||||
// update the search box with the underlying values from the
|
||||
// search suggestions.
|
||||
this.listen()
|
||||
}
|
||||
|
||||
|
@ -1841,6 +1844,11 @@
|
|||
return this.hide()
|
||||
}
|
||||
|
||||
, set_value: function () {
|
||||
var val = this.$menu.find('.active').data('typeahead-value')
|
||||
this.$element.val(val)
|
||||
}
|
||||
|
||||
, 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
|
||||
|
@ -1966,6 +1974,10 @@
|
|||
}
|
||||
|
||||
next.addClass('active')
|
||||
|
||||
if (this.options.naturalSearch) {
|
||||
this.set_value();
|
||||
}
|
||||
}
|
||||
|
||||
, prev: function (event) {
|
||||
|
@ -1977,6 +1989,10 @@
|
|||
}
|
||||
|
||||
prev.addClass('active')
|
||||
|
||||
if (this.options.naturalSearch) {
|
||||
this.set_value();
|
||||
}
|
||||
}
|
||||
|
||||
, listen: function () {
|
||||
|
|
Loading…
Reference in New Issue