From 7da862e09a32148fbb96e803825335b8b6d1cb30 Mon Sep 17 00:00:00 2001 From: Zbynek Konecny Date: Thu, 15 Aug 2024 14:36:45 +0200 Subject: [PATCH] Allow plugins to customize number of suggestions in autocomplete --- war/src/main/js/components/autocomplete/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/war/src/main/js/components/autocomplete/index.js b/war/src/main/js/components/autocomplete/index.js index be4350b7aad9..9caefc6e242e 100644 --- a/war/src/main/js/components/autocomplete/index.js +++ b/war/src/main/js/components/autocomplete/index.js @@ -43,9 +43,13 @@ function init() { }; } + function getMaxSuggestionCount(e) { + return parseInt(e.dataset["maxsuggestions"]) || 10; + } + function createAndShowDropdown(e, suggestions) { const items = suggestions - .splice(0, 10) + .splice(0, getMaxSuggestionCount(e)) .map((s) => convertSuggestionToItem(s, e)); if (!e.dropdown) { Utils.generateDropdown(