From f5b306dca62d3cb1f0985a39e39cd12c9d23a57e Mon Sep 17 00:00:00 2001 From: Maarten de Keizer Date: Tue, 26 Jul 2022 11:57:24 +0200 Subject: [PATCH] Autocomplete: Don't add plugins automaticly when defined #379 --- src/Autocomplete/assets/src/controller.ts | 27 +++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Autocomplete/assets/src/controller.ts b/src/Autocomplete/assets/src/controller.ts index 2b6eacf2d1c..151ac6ae99b 100644 --- a/src/Autocomplete/assets/src/controller.ts +++ b/src/Autocomplete/assets/src/controller.ts @@ -46,18 +46,21 @@ export default class extends Controller { #getCommonConfig(): Partial { const plugins: any = {} - // multiple values excepted if this is NOT A select (i.e. input) or a multiple select - const isMultiple = !this.selectElement || this.selectElement.multiple; - if (!this.formElement.disabled && !isMultiple) { - plugins.clear_button = { title: '' }; - } - - if (isMultiple) { - plugins.remove_button = { title: '' }; - } - - if (this.urlValue) { - plugins.virtual_scroll = {}; + // automaticly add plugins when NOT explicit configured + if (!this.tomSelectOptionsValue || !this.tomSelectOptionsValue.plugins !== undefined) { + // multiple values excepted if this is NOT A select (i.e. input) or a multiple select + const isMultiple = !this.selectElement || this.selectElement.multiple; + if (!this.formElement.disabled && !isMultiple) { + plugins.clear_button = { title: '' }; + } + + if (isMultiple) { + plugins.remove_button = { title: '' }; + } + + if (this.urlValue) { + plugins.virtual_scroll = {}; + } } const config: Partial = {