Fix contacts menu for IE11

IE11 triggers an 'input' event whenever an input is focussed
or loses focus. Thus this causes an endless loading loop as soon
as the view is re-rendered. To prevent this, this remembers the
previous search term and ignores events where the term has not
changed.

Fixes https://github.com/nextcloud/server/issues/5281

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2017-10-09 15:09:11 +02:00
parent 5304598296
commit f0d96ed7e1
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
1 changed files with 13 additions and 2 deletions

View File

@ -287,6 +287,9 @@
/** @type {undefined|ContactCollection} */
_contacts: undefined,
/** @type {string} */
_searchTerm: '',
events: {
'input #contactsmenu-search': '_onSearch'
},
@ -294,8 +297,16 @@
/**
* @returns {undefined}
*/
_onSearch: _.debounce(function() {
this.trigger('search', this.$('#contactsmenu-search').val());
_onSearch: _.debounce(function(e) {
var searchTerm = this.$('#contactsmenu-search').val();
// IE11 triggers an 'input' event after the view has been rendered
// resulting in an endless loading loop. To prevent this, we remember
// the last search term to savely ignore some events
// See https://github.com/nextcloud/server/issues/5281
if (searchTerm !== this._searchTerm) {
this.trigger('search', this.$('#contactsmenu-search').val());
this._searchTerm = searchTerm;
}
}, 700),
/**