From 35037648bde70e5ee505477fb0a58e70db4ef176 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sun, 14 May 2023 18:20:26 +0200 Subject: [PATCH] Disallow using onclick: action with confirm: --- app/helpers/application_helper.rb | 4 ++-- app/views/users/registrations/edit.html.erb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4d1acee..4ee7125 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -87,8 +87,8 @@ module ApplicationHelper name = svg_tag("pictograms/#{image}") + name if image html_options[:class] = class_names(html_options[:class], "button", active: current == :active) - if html_options[:confirm] - html_options[:onclick] = "return confirm('#{html_options.delete(:confirm)}');" + if html_options[:onclick]&.is_a? Hash + html_options[:onclick] = "return confirm('#{html_options[:onclick][:confirm]}');" end send "#{type}_to", name, options, html_options diff --git a/app/views/users/registrations/edit.html.erb b/app/views/users/registrations/edit.html.erb index e9f9bff..0082e45 100644 --- a/app/views/users/registrations/edit.html.erb +++ b/app/views/users/registrations/edit.html.erb @@ -4,9 +4,8 @@ request.referer.present? ? :back : root_url %>
- <%# TODO: make confirm dialog work %> <%= image_button_to t(".delete"), "account-remove-outline", user_registration_path, - class: "dangerous", method: :delete, confirm: t(".confirm_delete") %> + class: "dangerous", method: :delete, onclick: {confirm: t(".confirm_delete")} %>
<% end %>