[Rt-commit] rt branch, 4.6/selectize-multiple-user-inputs, updated. rt-4.4.4-780-g51a17eb01
? sunnavy
sunnavy at bestpractical.com
Thu Feb 13 17:37:56 EST 2020
The branch, 4.6/selectize-multiple-user-inputs has been updated
via 51a17eb01ace9df228acb4927b1a8622dd7636eb (commit)
from e03fc225aa5f6d56682283dea491ef001e61c0dc (commit)
Summary of changes:
share/html/Elements/EmailInput | 1 +
share/static/js/autocomplete.js | 6 ++++++
2 files changed, 7 insertions(+)
- Log -----------------------------------------------------------------
commit 51a17eb01ace9df228acb4927b1a8622dd7636eb
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Feb 14 06:23:05 2020 +0800
Explicitly set items so default values with multiple items could work
It's probably a selectize bug that only the first item gets rendered
even when there are multiple items in a text input. This commit gets
around it by explicitly setting default items.
diff --git a/share/html/Elements/EmailInput b/share/html/Elements/EmailInput
index 05de5cea1..c312db266 100644
--- a/share/html/Elements/EmailInput
+++ b/share/html/Elements/EmailInput
@@ -83,6 +83,7 @@
% if (@options) {
data-options="<% JSON(\@options) %>"
+ data-items="<% JSON([ map { $_->{value} } @options ]) %>"
% }
/>
diff --git a/share/static/js/autocomplete.js b/share/static/js/autocomplete.js
index b2acf6b7f..1255c2032 100644
--- a/share/static/js/autocomplete.js
+++ b/share/static/js/autocomplete.js
@@ -50,9 +50,15 @@ window.RT.Autocomplete.bind = function(from) {
if (what === 'Users' && input.is('[data-autocomplete-multiple]')) {
var options = input.attr('data-options');
+ var items = input.attr('data-items');
input.selectize({
plugins: ['remove_button', 'rt_drag_drop'],
options: options ? JSON.parse(options) : null,
+
+ // If input value contains multiple items, selectize only
+ // renders the first item somehow. Here we explicitly set
+ // items to get around this issue.
+ items: items ? JSON.parse(items) : null,
valueField: 'value',
labelField: 'label',
searchField: ['label', 'value', 'text'],
-----------------------------------------------------------------------
More information about the rt-commit
mailing list