Skip to content

Commit 7c59e13

Browse files
committed
Fix: show success toast when saving column preferences
When saving column defaults, the flash was rendered inside the turbo_stream.replace of the form element, placing it inside the dropdown with incorrect styling instead of the top-level #flashes container. Fix: separate the flash into its own turbo_stream.append targeting #flashes, matching the pattern used by destroy_product_variant and clone turbo stream views. Also tightened the spec to assert the flash appears in #flashes with .flash.success class, not just that the text is present. Fixes openfoodfoundation#13966
1 parent 939ae20 commit 7c59e13

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
= turbo_stream.replace "bulk_admin_column_preferences_form" do
2-
= render partial: "admin/shared/flashes", locals: { flashes: flash } if defined? flash
32
= render partial: 'form', locals: { action: }
3+
= turbo_stream.append "flashes" do
4+
= render partial: "admin/shared/flashes", locals: { flashes: flash }

spec/system/admin/products_v3/actions_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ def expect_other_columns_visible
8585
end
8686

8787
def save_preferences
88-
# Preference saved
8988
click_on "Save as default"
90-
expect(page).to have_content "Column preferences saved"
89+
# Flash appears at top level with success styling (not error), fixes #13966
90+
within "#flashes" do
91+
expect(page).to have_css ".flash.success", text: "Column preferences saved"
92+
end
9193
refresh
9294
end
9395
end

0 commit comments

Comments
 (0)