Jake Vanderwerf
2026-01-04 d38d825e3484d822ea3c1f0fb1df37ecf386b18a
assets/js/concise/TaxonomySelector.js
@@ -480,7 +480,13 @@
   initAutocomplete()
   {
      this.autocompleteHandler = window.debounce((e) => this.handleAutocomplete(e), 300);
      this.autocompleteHandler = (e) => {
         window.debouncer.schedule(
            'taxonomy-autocomplete',
            () => this.handleAutocomplete(e),
            300
         );
      };
      document.addEventListener('input', this.autocompleteHandler);
      document.addEventListener('blur', this.cleanupAutocomplete.bind(this));
      // Preload taxonomy data on focus
@@ -1126,11 +1132,17 @@
         });
      }
      // Use stored current query instead of debounced one
      // Only show create button if exact match doesn't exist
      const currentQuery = field.currentAutocompleteQuery || query;
      if (field.canCreate && currentQuery && window.jvbTaxCreator) {
         const createOption = this.createNewTermOption(currentQuery);
         dropdown.appendChild(createOption);
         const exactMatch = terms.find(term =>
            term.name.toLowerCase() === currentQuery.toLowerCase()
         );
         if (!exactMatch) {
            const createOption = this.createNewTermOption(currentQuery);
            dropdown.appendChild(createOption);
         }
      }
      dropdown.hidden = false;
@@ -1545,5 +1557,10 @@
 * Initialize singleton
 */
document.addEventListener('DOMContentLoaded', function() {
   window.jvbSelector = new TaxonomySelector();
   window.auth.subscribe((event) => {
      if (event === 'auth-loaded') {
         window.jvbSelector = new TaxonomySelector();
      }
   });
});