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.

Improve Checkout special instructions UX (adding autogrow stimulus controller)

Damian Legawiec12cc3f926bb4
diff --git a/admin/config/importmap.rb b/admin/config/importmap.rb
index 58e06822b3..86ef78ea0b 100644
--- a/admin/config/importmap.rb
+++ b/admin/config/importmap.rb
@@ -23,7 +23,6 @@ pin '@stimulus-components/rails-nested-form', to: '@stimulus-components--rails-n
pin 'stimulus-notification', preload: ['application-spree-admin'] # @2.2.0
pin 'stimulus-password-visibility', preload: ['application-spree-admin'] # @2.1.1
pin 'stimulus-sortable', preload: ['application-spree-admin'] # @4.1.1
-pin 'stimulus-textarea-autogrow', preload: ['application-spree-admin'] # @4.1.0
pin 'hotkeys-js', preload: ['application-spree-admin'] # @3.13.9
pin 'stimulus-use', preload: ['application-spree-admin'] # @0.51.3
pin 'stimulus-checkbox-select-all', preload: ['application-spree-admin'] # @5.3.0
diff --git a/core/config/importmap.rb b/core/config/importmap.rb
index 6fe5693891..5f89ed900c 100644
--- a/core/config/importmap.rb
+++ b/core/config/importmap.rb
@@ -3,6 +3,7 @@ pin '@rails/request.js', to: '@rails--request.js.js', preload: ['application-spr
pin 'tailwindcss-stimulus-components', preload: ['application-spree-storefront', 'application-spree-admin'] # @3.0.4
pin 'stimulus-reveal-controller', preload: ['application-spree-admin'] # @4.1.0
pin '@stimulus-components/auto-submit', to: '@stimulus-components--auto-submit.js', preload: ['application-spree-admin'] # @6.0.0
+pin 'stimulus-textarea-autogrow', preload: ['application-spree-admin'] # @4.1.0
pin_all_from Spree::Core::Engine.root.join('app/javascript/spree/core/controllers'),
under: 'spree/core/controllers',
diff --git a/admin/vendor/javascript/stimulus-textarea-autogrow.js b/core/vendor/javascript/stimulus-textarea-autogrow.js
similarity index 100%
rename from admin/vendor/javascript/stimulus-textarea-autogrow.js
rename to core/vendor/javascript/stimulus-textarea-autogrow.js
diff --git a/storefront/app/javascript/spree/storefront/application.js b/storefront/app/javascript/spree/storefront/application.js
index 04a0b3c5b0..41633a22e6 100644
--- a/storefront/app/javascript/spree/storefront/application.js
+++ b/storefront/app/javascript/spree/storefront/application.js
@@ -58,6 +58,7 @@ const controllers = [
'slideover-account',
'slideover',
'sticky-button',
+ 'textarea-autogrow',
'toggle-menu',
'turbo-stream-form',
'wished-item',
@@ -74,6 +75,7 @@ const manifest = {
"reveal": "stimulus-reveal-controller",
"scroll-to": "stimulus-scroll-to",
"read-more": "stimulus-read-more",
+ "textarea-autogrow": "stimulus-textarea-autogrow"
}
import { lazyLoadControllersFromManifest } from "spree/storefront/helpers/lazy_load_controllers_with_manifest"
diff --git a/storefront/app/views/spree/checkout/_special_instructions.html.erb b/storefront/app/views/spree/checkout/_special_instructions.html.erb
index 351be8502d..1b7d60f186 100644
--- a/storefront/app/views/spree/checkout/_special_instructions.html.erb
+++ b/storefront/app/views/spree/checkout/_special_instructions.html.erb
@@ -4,7 +4,7 @@
<%= I18n.t('activerecord.attributes.spree/order.special_instructions') %>
</h5>
<div class="form-group">
- <%= form.text_area :special_instructions, class: 'w-full text-input', rows: 2, placeholder: Spree.t('storefront.checkout.special_instructions_placeholder') %>
+ <%= form.text_area :special_instructions, class: 'w-full text-input', rows: 2, placeholder: Spree.t('storefront.checkout.special_instructions_placeholder'), data: { controller: 'textarea-autogrow' } %>
</div>
</div>
<% end %>