Improved select controls and added remove_buttons to multiple select inputs

This commit is contained in:
Jan Böhmer 2024-08-07 00:52:27 +02:00
parent 79da0518c2
commit f6a2467eae
2 changed files with 9 additions and 1 deletions

View file

@ -40,7 +40,7 @@ export default class extends Controller {
let settings = {
plugins: [],
plugins: ["clear_button"],
allowEmptyOption: true,
selectOnTab: true,
maxOptions: null,
@ -54,6 +54,12 @@ export default class extends Controller {
//Load the drag_drop plugin if the select is ordered
if (this.element.dataset.orderedValue) {
settings.plugins.push('drag_drop');
settings.plugins.push("caret_position");
}
//If multiple items can be selected, enable the remove_button plugin
if (this.element.multiple) {
settings.plugins.push('remove_button');
}
this._tomSelect = new TomSelect(this.element, settings);

View file

@ -20,6 +20,8 @@
import {Controller} from "@hotwired/stimulus";
import TomSelect from "tom-select";
// TODO: Merge with select_controller.js
export default class extends Controller {
_tomSelect;