diff --git a/src/Autocomplete/assets/dist/controller.js b/src/Autocomplete/assets/dist/controller.js index c6e9660b1d6..7533c4b27ae 100644 --- a/src/Autocomplete/assets/dist/controller.js +++ b/src/Autocomplete/assets/dist/controller.js @@ -15,7 +15,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ -/* global Reflect, Promise, SuppressedError, Symbol */ +/* global Reflect, Promise, SuppressedError, Symbol, Iterator */ function __classPrivateFieldGet(receiver, state, kind, f) { @@ -227,7 +227,11 @@ _default_1_instances = new WeakSet(), _default_1_getCommonConfig = function _def const plugins = {}; const isMultiple = !this.selectElement || this.selectElement.multiple; if (!this.formElement.disabled && !isMultiple) { - plugins.clear_button = { title: '' }; + const placeholderOptions = Array.from(this.selectElement.options) + .filter((option) => option.value === ''); + if (placeholderOptions.length) { + plugins.clear_button = { title: '' }; + } } if (isMultiple) { plugins.remove_button = { title: '' }; diff --git a/src/Autocomplete/assets/src/controller.ts b/src/Autocomplete/assets/src/controller.ts index af7f096a387..ce5f933bb97 100644 --- a/src/Autocomplete/assets/src/controller.ts +++ b/src/Autocomplete/assets/src/controller.ts @@ -127,10 +127,15 @@ export default class extends Controller { #getCommonConfig(): Partial { const plugins: TPluginHash = {}; - // multiple values excepted if this is NOT A select (i.e. input) or a multiple select + // Multiple values expected 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: '' }; + // Only activate clear button plugin when there is a placeholder option + const placeholderOptions = Array.from(this.selectElement.options) + .filter((option) => option.value === ''); + if (placeholderOptions.length) { + plugins.clear_button = { title: '' }; + } } if (isMultiple) {