From f06267dd0b9c24a98639211321dc9fc12ae6b415 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sat, 30 Mar 2024 12:00:04 +0100 Subject: [PATCH] fix typeahead menu --- CHANGELOG | 1 + styles/bootstrap/bootstrap/js/bootstrap-typeahead.js | 7 ++++++- views/bootstrap4/styles/application.js | 11 ++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f9d132765..f8709ab7a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ - set default language in login form if language selector is turned off - do not show full list of notifiers to none admins - do not list document/folders in sequence selector if its number exceeds 50 +- typeahead menu works with arrow keys again, wait 1 sec. before searching -------------------------------------------------------------------------------- Changes in version 5.1.33 diff --git a/styles/bootstrap/bootstrap/js/bootstrap-typeahead.js b/styles/bootstrap/bootstrap/js/bootstrap-typeahead.js index e2b70118e..645e40fac 100644 --- a/styles/bootstrap/bootstrap/js/bootstrap-typeahead.js +++ b/styles/bootstrap/bootstrap/js/bootstrap-typeahead.js @@ -38,6 +38,7 @@ this.source = this.options.source this.$menu = $(this.options.menu) this.shown = false + this.timeout = null this.listen() } @@ -254,7 +255,11 @@ break default: - this.lookup() + clearTimeout(this.timeout); + + this.timeout = setTimeout(() => { + this.lookup() + }, 1000); } e.stopPropagation() diff --git a/views/bootstrap4/styles/application.js b/views/bootstrap4/styles/application.js index d2375d10a..46e6a7af6 100644 --- a/views/bootstrap4/styles/application.js +++ b/views/bootstrap4/styles/application.js @@ -93,8 +93,8 @@ function initMost() { * for each hit and render could only process strings. * */ $("#searchfield").typeahead({ /* {{{ */ - menu: '', - item: '
  • ', + menu: '', + item: '', minLength: 3, items: 100, /* the query will limit the number of hits */ source: function(query, process) { @@ -170,7 +170,8 @@ function initMost() { items = $(items).map(function (i, item) { i = $(that.options.item).attr('data-value', item.name).attr('data-id', item.id).attr('data-type', item.type); - i.find('a').html(that.highlighter(item)) + /* i is already the 'a' tag, there is no 'li' as used by bootstrap 2 */ + i./*find('a').*/html(that.highlighter(item)) return i[0] }) @@ -184,7 +185,7 @@ function initMost() { /* Document chooser */ $("[id^=choosedocsearch]").typeahead({ /* {{{ */ menu: '', - item: '
  • ', + item: '', minLength: 3, source: function(query, process) { // console.log(this.options); @@ -222,7 +223,7 @@ function initMost() { items = $(items).map(function (i, item) { i = $(that.options.item).attr('data-value', item.name).attr('data-id', item.id).attr('data-type', item.type); - i.find('a').html(that.highlighter(item)) + i./*find('a').*/html(that.highlighter(item)) return i[0] })