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.

Admin: fixed dropdowns overlapping issues

Damian Legawiec780af6ce21d5
diff --git a/admin/app/helpers/spree/admin/dropdown_helper.rb b/admin/app/helpers/spree/admin/dropdown_helper.rb
index a350ee2ca8..ad8270acc4 100644
--- a/admin/app/helpers/spree/admin/dropdown_helper.rb
+++ b/admin/app/helpers/spree/admin/dropdown_helper.rb
@@ -3,7 +3,23 @@ module Spree
module DropdownHelper
def dropdown(options = {}, &block)
options[:class] = ['dropdown'] + Array(options[:class])
- options[:data] = { controller: 'dropdown' }.merge(options[:data] || {})
+
+ # Extract direction option for backward compatibility and convert to Floating UI placement
+ placement = case options.delete(:direction)
+ when 'left'
+ 'bottom-end'
+ when 'top'
+ 'top-start'
+ when 'top-left'
+ 'top-end'
+ else
+ options[:placement] || 'bottom-start'
+ end
+
+ options[:data] = {
+ controller: 'dropdown',
+ dropdown_placement_value: placement
+ }.merge(options[:data] || {})
content_tag(:div, options, &block)
end
@@ -19,22 +35,8 @@ module Spree
def dropdown_menu(options = {}, &block)
options[:class] = ['dropdown-container hidden'] + Array(options[:class])
-
- # Extract direction option for backward compatibility and convert to Floating UI placement
- placement = case options.delete(:direction)
- when 'left'
- 'bottom-end'
- when 'top'
- 'top-start'
- when 'top-left'
- 'top-end'
- else
- options[:placement] || 'bottom-start'
- end
-
options[:data] = {
- dropdown_target: 'menu',
- dropdown_placement_value: placement
+ dropdown_target: 'menu'
}.merge(options[:data] || {})
content_tag(:div, options, &block)
diff --git a/admin/app/views/spree/admin/gift_cards/_filters.html.erb b/admin/app/views/spree/admin/gift_cards/_filters.html.erb
index f447eb2fb7..fe67b7cf03 100644
--- a/admin/app/views/spree/admin/gift_cards/_filters.html.erb
+++ b/admin/app/views/spree/admin/gift_cards/_filters.html.erb
@@ -6,7 +6,8 @@
class: "filter-wrap",
data: {
controller: "filters dropdown",
- filters_url_value: request.url
+ filters_url_value: request.url,
+ dropdown_placement_value: "bottom-end"
} do |f| %>
<%= hidden_field_tag :frame_name, frame_name if frame_name.present? %>
diff --git a/admin/app/views/spree/admin/orders/_filters.html.erb b/admin/app/views/spree/admin/orders/_filters.html.erb
index 581b960758..7c50b3563d 100644
--- a/admin/app/views/spree/admin/orders/_filters.html.erb
+++ b/admin/app/views/spree/admin/orders/_filters.html.erb
@@ -15,7 +15,8 @@
class: "filter-wrap",
data: {
controller: "filters dropdown",
- filters_url_value: request.url
+ filters_url_value: request.url,
+ dropdown_placement_value: "bottom-end"
} do |f| %>
<%= hidden_field_tag :frame_name, frame_name if frame_name.present? %>
@@ -27,15 +28,13 @@
date_from_input_name: "q[created_at_gt]",
date_to_input_name: "q[created_at_lt]",
date_from_value: params.dig(:q, :created_at_gt),
- date_to_value: params.dig(:q, :created_at_lt),
- dropdown_direction: "right" %>
+ date_to_value: params.dig(:q, :created_at_lt) %>
<% else %>
<%= render "spree/admin/shared/calendar_range_picker",
date_from_input_name: "q[completed_at_gt]",
date_to_input_name: "q[completed_at_lt]",
date_from_value: params.dig(:q, :completed_at_gt),
- date_to_value: params.dig(:q, :completed_at_lt),
- dropdown_direction: "right" %>
+ date_to_value: params.dig(:q, :completed_at_lt) %>
<% end %>
<%= render "spree/admin/orders/table_filter_dropdown" %>
diff --git a/admin/app/views/spree/admin/page_builder/_add_block.html.erb b/admin/app/views/spree/admin/page_builder/_add_block.html.erb
index 1c6183d0a8..32b704a917 100644
--- a/admin/app/views/spree/admin/page_builder/_add_block.html.erb
+++ b/admin/app/views/spree/admin/page_builder/_add_block.html.erb
@@ -6,7 +6,7 @@
<%= icon("circle-plus") %>
Add block
<% end %>
- <%= dropdown_menu direction: 'top-left' do %>
+ <%= dropdown_menu do %>
<% section.available_blocks_to_add.each do |block_class| %>
<a href="#" class="dropdown-item btn-sm"
data-action="click->block-form#addBlock"
diff --git a/admin/app/views/spree/admin/page_builder/_pages_dropdown.html.erb b/admin/app/views/spree/admin/page_builder/_pages_dropdown.html.erb
index f5c6cdeb4a..a5bcbc7ee8 100644
--- a/admin/app/views/spree/admin/page_builder/_pages_dropdown.html.erb
+++ b/admin/app/views/spree/admin/page_builder/_pages_dropdown.html.erb
@@ -1,4 +1,4 @@
-<%= dropdown id: 'pages_dropdown' do %>
+<%= dropdown id: 'pages_dropdown', direction: 'left' do %>
<%= dropdown_toggle class: 'btn-light' do %>
<span class="d-flex align-items-center pr-5">
<%= icon @page.icon_name, class: 'mr-2' %>
@@ -6,7 +6,7 @@
</span>
<%= icon 'selector', class: 'mr-0 ml-2 mb-0 text-muted' %>
<% end %>
- <%= dropdown_menu direction: 'left', style: 'min-width: 250px' do %>
+ <%= dropdown_menu style: 'min-width: 250px' do %>
<% @theme.pages.standard.order(name: :asc).find_all(&:customizable?).each do |page| %>
<%= active_link_to spree.edit_admin_theme_path(@theme, theme_preview_id: @theme_preview.id, page_id: page.id), class: 'dropdown-item', active: @page == page, data: { turbo_prefetch: false } do %>
<%= icon page.icon_name, class: 'mr-2' %>
diff --git a/admin/app/views/spree/admin/products/_bulk_operations.html.erb b/admin/app/views/spree/admin/products/_bulk_operations.html.erb
index f1360e75f6..799a22cebc 100644
--- a/admin/app/views/spree/admin/products/_bulk_operations.html.erb
+++ b/admin/app/views/spree/admin/products/_bulk_operations.html.erb
@@ -18,11 +18,11 @@
url: spree.bulk_status_update_admin_products_path(status: :draft)
) %>
- <%= dropdown do %>
+ <%= dropdown direction: 'top' do %>
<%= dropdown_toggle do %>
<%= icon('dots-vertical', class: "mr-0") %>
<% end %>
- <%= dropdown_menu direction: 'top', class: 'mb-2' do %>
+ <%= dropdown_menu class: 'mb-2' do %>
<%= bulk_action_link(
Spree.t("admin.bulk_ops.products.title.set_status", status: :archived),
spree.bulk_modal_admin_products_path(kind: :set_status, status: :archived),
diff --git a/admin/app/views/spree/admin/shared/_calendar_range_picker.html.erb b/admin/app/views/spree/admin/shared/_calendar_range_picker.html.erb
index 75ec9a8efd..9d6ec6e938 100644
--- a/admin/app/views/spree/admin/shared/_calendar_range_picker.html.erb
+++ b/admin/app/views/spree/admin/shared/_calendar_range_picker.html.erb
@@ -7,7 +7,7 @@
<% dropdown_direction ||= 'left' %>
-<%= dropdown data: { controller: 'dropdown calendar-range', action: 'click->calendar-range#open' }, class: 'h-100' do %>
+<%= dropdown direction: dropdown_direction, data: { controller: 'dropdown calendar-range', action: 'click->calendar-range#open' }, class: 'h-100' do %>
<%= dropdown_toggle class: css_classes do %>
<%= icon('calendar', class: 'mr-2') %>
<div data-calendar-range-target="label">
@@ -18,7 +18,7 @@
<% end %>
</div>
<% end %>
- <%= dropdown_menu direction: dropdown_direction, class: "pt-2 px-2 pb-1" do %>
+ <%= dropdown_menu class: "pt-2 px-2 pb-1" do %>
<div data-calendar-range-target="picker" class="d-none"></div>
<% end %>
diff --git a/admin/app/views/spree/admin/shared/_new_item_dropdown.html.erb b/admin/app/views/spree/admin/shared/_new_item_dropdown.html.erb
index f7e96d6237..231816e8af 100644
--- a/admin/app/views/spree/admin/shared/_new_item_dropdown.html.erb
+++ b/admin/app/views/spree/admin/shared/_new_item_dropdown.html.erb
@@ -2,7 +2,7 @@
<%= dropdown_toggle class: 'btn-light btn-sm px-1' do %>
<%= icon 'plus', class: 'mr-0' %>
<% end %>
- <%= dropdown_menu direction: 'left' do %>
+ <%= dropdown_menu do %>
<%= link_to_with_icon 'shopping-bag-plus', Spree.t(:new_order), spree.new_admin_order_path, class: "dropdown-item" if can?(:manage, Spree::Order) %>
<%= link_to spree.new_admin_product_path, class: 'dropdown-item' do %>
diff --git a/admin/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb b/admin/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb
index b44cd7b65a..1c671f9140 100644
--- a/admin/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb
+++ b/admin/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb
@@ -4,7 +4,7 @@
<%= store_admin_icon(current_store, height: 32, width: 32) %>
<%= truncate(current_store.name, length: 10) %>
<% end %>
- <%= dropdown_menu class: 'ml-2', direction: 'left' do %>
+ <%= dropdown_menu class: 'ml-2' do %>
<%= link_to current_store.formatted_url_or_custom_domain, class: 'dropdown-item', target: '_blank' do %>
<%= icon 'eye' %>
<%= Spree.t(:view_store) %>
diff --git a/admin/app/views/spree/admin/users/_filters.html.erb b/admin/app/views/spree/admin/users/_filters.html.erb
index abdb95076e..1afa0aed42 100644
--- a/admin/app/views/spree/admin/users/_filters.html.erb
+++ b/admin/app/views/spree/admin/users/_filters.html.erb
@@ -6,8 +6,7 @@
date_from_input_name: "q[created_at_gt]",
date_to_input_name: "q[created_at_lt]",
date_from_value: params.dig(:q, :created_at_gt),
- date_to_value: params.dig(:q, :created_at_lt),
- dropdown_direction: "right" %>
+ date_to_value: params.dig(:q, :created_at_lt) %>
<%= render 'spree/admin/shared/filters_button' %>
</div>