From d655b6872dbc944edf2f449f0e4b6d312ffe61f3 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 22 Dec 2021 19:13:14 +0000 Subject: [PATCH] Don't progressively enhance select options multiple times --- .../controllers/accessible_autocomplete_controller.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/webpacker/controllers/accessible_autocomplete_controller.js b/app/webpacker/controllers/accessible_autocomplete_controller.js index db34213ee..5ca1b2c35 100644 --- a/app/webpacker/controllers/accessible_autocomplete_controller.js +++ b/app/webpacker/controllers/accessible_autocomplete_controller.js @@ -4,9 +4,11 @@ import 'accessible-autocomplete/dist/accessible-autocomplete.min.css' export default class extends Controller { connect() { - accessibleAutocomplete.enhanceSelectElement({ - defaultValue: '', - selectElement: this.element - }) + if(document.querySelectorAll(".autocomplete__input").length == 0){ + accessibleAutocomplete.enhanceSelectElement({ + defaultValue: '', + selectElement: this.element + }) + } } }