Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Small tweaks to Select2 to match previous behavior.

Matthew Kennedy114adcf60b55
diff --git a/backend/app/assets/javascripts/spree/backend/option_type_autocomplete.js b/backend/app/assets/javascripts/spree/backend/option_type_autocomplete.js
index 6b34a4093d..098126a837 100644
--- a/backend/app/assets/javascripts/spree/backend/option_type_autocomplete.js
+++ b/backend/app/assets/javascripts/spree/backend/option_type_autocomplete.js
@@ -4,7 +4,6 @@ $.fn.optionTypeAutocomplete = function () {
this.select2({
minimumInputLength: 2,
multiple: true,
- allowClear: true,
ajax: {
url: Spree.routes.option_types_api,
datatype: 'json',
diff --git a/backend/app/assets/javascripts/spree/backend/option_value_picker.js b/backend/app/assets/javascripts/spree/backend/option_value_picker.js
index d358b477b9..f44298efad 100644
--- a/backend/app/assets/javascripts/spree/backend/option_value_picker.js
+++ b/backend/app/assets/javascripts/spree/backend/option_value_picker.js
@@ -35,7 +35,6 @@ $.fn.optionValueAutocomplete = function (options) {
this.select2({
multiple: multiple,
minimumInputLength: 1,
- allowClear: true,
ajax: {
url: Spree.routes.option_values_api,
dataType: 'json',
diff --git a/backend/app/assets/javascripts/spree/backend/spree-select2.js b/backend/app/assets/javascripts/spree/backend/spree-select2.js
index 681ff43778..af6e6d3292 100644
--- a/backend/app/assets/javascripts/spree/backend/spree-select2.js
+++ b/backend/app/assets/javascripts/spree/backend/spree-select2.js
@@ -1,12 +1,8 @@
document.addEventListener('DOMContentLoaded', function() {
// Inititate Select2 on any select element with the class .select2
$('select.select2').select2({
- // change that
- allowClear: false,
- placeholder: {
- id: '-1', // the value of the option
- text: 'Select an option'
- }
+ allowClear: true,
+ placeholder: 'Select an option'
})
})
diff --git a/backend/app/assets/javascripts/spree/backend/taxon_autocomplete.js b/backend/app/assets/javascripts/spree/backend/taxon_autocomplete.js
index 606e3e83e6..2986e93f92 100644
--- a/backend/app/assets/javascripts/spree/backend/taxon_autocomplete.js
+++ b/backend/app/assets/javascripts/spree/backend/taxon_autocomplete.js
@@ -14,7 +14,6 @@ $.fn.taxonAutocomplete = function() {
multiple: true,
placeholder: Spree.translations.taxon_placeholder,
minimumInputLength: 2,
- allowClear: true,
ajax: {
url: Spree.routes.taxons_api,
dataType: 'json',
diff --git a/backend/app/views/spree/admin/products/_form.html.erb b/backend/app/views/spree/admin/products/_form.html.erb
index 97fb30f6f8..6fc6e93953 100644
--- a/backend/app/views/spree/admin/products/_form.html.erb
+++ b/backend/app/views/spree/admin/products/_form.html.erb
@@ -195,7 +195,7 @@
<%= f.label :taxon_ids, Spree.t(:taxons) %>
<% if can? :modify, Spree::Classification %>
- <%= f.select :taxon_ids, options_from_collection_for_select(@product.taxons, :id, :pretty_name, @product.taxons.pluck(:id)), { include_hidden: true }, multiple: true, class: 'd-block w-100' %>
+ <%= f.select :taxon_ids, options_from_collection_for_select(@product.taxons, :id, :pretty_name, @product.taxons.pluck(:id)), { include_hidden: true }, multiple: true, class: 'select2-hidden-accessible' %>
<% elsif @product.taxons.any? %>
<ul class="text_list">
<% @product.taxons.each do |taxon| %>
@@ -214,7 +214,7 @@
<%= f.label :option_type_ids, Spree.t(:option_types) %>
<% if can? :modify, Spree::ProductOptionType %>
- <%= f.select :option_type_ids, options_from_collection_for_select(Spree::OptionType.all, :id, :name, @product.option_types.pluck(:id)), { include_hidden: true }, multiple: true, class: 'd-block w-100' %>
+ <%= f.select :option_type_ids, options_from_collection_for_select(Spree::OptionType.all, :id, :name, @product.option_types.pluck(:id)), { include_hidden: true }, multiple: true, class: 'select2-hidden-accessible' %>
<% elsif @product.option_types.any? %>
<ul class="text_list">
<% @product.option_types.each do |type| %>