diff --git a/assets/controllers/elements/select_controller.js b/assets/controllers/elements/select_controller.js index 1740c8fb..cdafe4d0 100644 --- a/assets/controllers/elements/select_controller.js +++ b/assets/controllers/elements/select_controller.js @@ -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); diff --git a/assets/controllers/elements/select_multiple_controller.js b/assets/controllers/elements/select_multiple_controller.js index 85680af0..df37871d 100644 --- a/assets/controllers/elements/select_multiple_controller.js +++ b/assets/controllers/elements/select_multiple_controller.js @@ -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;