From 786288772402b7ef6e362eb29fa24caa31c25635 Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 28 Nov 2023 14:24:38 +0200 Subject: [PATCH 1/5] fix: firefox record selection persists on reload --- app/helpers/avo/resources_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/helpers/avo/resources_helper.rb b/app/helpers/avo/resources_helper.rb index e5427a5e60..024e8483fa 100644 --- a/app/helpers/avo/resources_helper.rb +++ b/app/helpers/avo/resources_helper.rb @@ -46,6 +46,7 @@ def item_selector_input(floating: false, size: :md) type: "checkbox", name: t("avo.select_item"), title: t("avo.select_item"), + autocomplete: :off, class: "mx-3 rounded checked:bg-primary-400 focus:checked:!bg-primary-400 #{floating ? "absolute inset-auto left-0 mt-3 z-10 hidden group-hover:block checked:block" : ""} #{size.to_sym == :lg ? "w-5 h-5" : "w-4 h-4"}", data: { action: 'input->item-selector#toggle input->item-select-all#selectRow', @@ -59,6 +60,7 @@ def item_select_all_input type: "checkbox", name: t("avo.select_all"), title: t("avo.select_all"), + autocomplete: :off, class: "mx-3 rounded w-4 h-4 checked:bg-primary-400 focus:checked:!bg-primary-400", data: { action: "input->item-select-all#toggle", From 398af2ed7d48c6ffbd9d26330d2a42e8fedb150d Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 28 Nov 2023 15:09:19 +0200 Subject: [PATCH 2/5] fix actions_spec --- spec/system/avo/actions_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/system/avo/actions_spec.rb b/spec/system/avo/actions_spec.rb index 56abef95ec..0bc9b8b9a6 100644 --- a/spec/system/avo/actions_spec.rb +++ b/spec/system/avo/actions_spec.rb @@ -156,11 +156,9 @@ Avo::Actions::Sub::DummyAction.class_eval do self.no_confirmation = true - define_method(:redirect_handle) do |**args| + def handle(**args) redirect_to main_app.hey_path end - - alias_method :handle, :redirect_handle end visit "/admin/resources/users" From 2e7d8c53629fc360ec2fd70f8987bb62e5b7c0ea Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 28 Nov 2023 15:46:58 +0200 Subject: [PATCH 3/5] remove relative from tr to fix firefox row border-b render --- app/components/avo/index/table_row_component.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/avo/index/table_row_component.html.erb b/app/components/avo/index/table_row_component.html.erb index cab027677b..659131cbf2 100644 --- a/app/components/avo/index/table_row_component.html.erb +++ b/app/components/avo/index/table_row_component.html.erb @@ -1,6 +1,6 @@ <%# hover:z-[21] removed from tr class to solve flickering actions component on row controls and z-20 changed to z-21%> data-resource-name="<%= @resource.class.to_s %>" From e687b9b6bd5495fd393ea7a5343e2a06c67a288a Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 28 Nov 2023 16:03:25 +0200 Subject: [PATCH 4/5] try loading action --- spec/system/avo/actions_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/system/avo/actions_spec.rb b/spec/system/avo/actions_spec.rb index 0bc9b8b9a6..b6a230ea25 100644 --- a/spec/system/avo/actions_spec.rb +++ b/spec/system/avo/actions_spec.rb @@ -151,8 +151,6 @@ describe "redirects when no confirmation" do it "redirects to hey page" do - original_dummy_action = Avo::Actions::Sub::DummyAction.dup - Avo::Actions::Sub::DummyAction.class_eval do self.no_confirmation = true @@ -169,7 +167,7 @@ def handle(**args) expect(page).to have_text "hey en" Avo::Actions::Sub.send(:remove_const, "DummyAction") - Avo::Actions::Sub.const_set("DummyAction", original_dummy_action) + load(Rails.root.join("app/avo/actions/sub/dummy_action.rb")) end end From a522868188d4bca460aeb3b54ed5708844f5a21a Mon Sep 17 00:00:00 2001 From: Paul Bob Date: Tue, 28 Nov 2023 16:18:58 +0200 Subject: [PATCH 5/5] action for no confirmation redirect test --- .../avo/actions/test/no_confirmation_redirect.rb | 9 +++++++++ spec/dummy/app/avo/resources/user.rb | 1 + spec/system/avo/actions_spec.rb | 13 +------------ 3 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 spec/dummy/app/avo/actions/test/no_confirmation_redirect.rb diff --git a/spec/dummy/app/avo/actions/test/no_confirmation_redirect.rb b/spec/dummy/app/avo/actions/test/no_confirmation_redirect.rb new file mode 100644 index 0000000000..3788ba0a28 --- /dev/null +++ b/spec/dummy/app/avo/actions/test/no_confirmation_redirect.rb @@ -0,0 +1,9 @@ +class Avo::Actions::Test::NoConfirmationRedirect < Avo::BaseAction + self.name = "Test No Confirmation Redirect" + self.no_confirmation = true + self.standalone = true + + def handle(**args) + redirect_to main_app.hey_path + end +end diff --git a/spec/dummy/app/avo/resources/user.rb b/spec/dummy/app/avo/resources/user.rb index e5da9871f9..8955dfb863 100644 --- a/spec/dummy/app/avo/resources/user.rb +++ b/spec/dummy/app/avo/resources/user.rb @@ -67,6 +67,7 @@ def actions action Avo::Actions::ToggleAdmin action Avo::Actions::Sub::DummyAction action Avo::Actions::DownloadFile + action Avo::Actions::Test::NoConfirmationRedirect end def filters diff --git a/spec/system/avo/actions_spec.rb b/spec/system/avo/actions_spec.rb index b6a230ea25..2c864905ae 100644 --- a/spec/system/avo/actions_spec.rb +++ b/spec/system/avo/actions_spec.rb @@ -151,23 +151,12 @@ describe "redirects when no confirmation" do it "redirects to hey page" do - Avo::Actions::Sub::DummyAction.class_eval do - self.no_confirmation = true - - def handle(**args) - redirect_to main_app.hey_path - end - end - visit "/admin/resources/users" click_on "Actions" - click_on "Dummy action" + click_on "Test No Confirmation Redirect" expect(page).to have_text "hey en" - - Avo::Actions::Sub.send(:remove_const, "DummyAction") - load(Rails.root.join("app/avo/actions/sub/dummy_action.rb")) end end