From 624f9bf3d107488c67624de636171eeff10886ab Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 10 Nov 2024 06:45:26 +0000 Subject: [PATCH] Fixed duplicate "disabled" class in the context_menus_helper result (#23980, #41720). Patch by Katsuya HIDAKA (user:hidakatsuya). git-svn-id: https://svn.redmine.org/redmine/trunk@23226 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/context_menus_helper.rb | 10 +++++++--- test/helpers/context_menus_helper_test.rb | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/helpers/context_menus_helper.rb b/app/helpers/context_menus_helper.rb index bfabbbb4e..cb8153549 100644 --- a/app/helpers/context_menus_helper.rb +++ b/app/helpers/context_menus_helper.rb @@ -20,19 +20,23 @@ module ContextMenusHelper def context_menu_link(name, url, options={}) label = name - options[:class] ||= '' + css_classes = [options[:class]] + if options.delete(:selected) - options[:class] += ' icon disabled' + css_classes << 'icon disabled' options[:disabled] = true label = sprite_icon('checked', name) end + if options.delete(:disabled) options.delete(:method) options.delete(:data) options[:onclick] = 'return false;' - options[:class] += ' disabled' + css_classes << 'disabled' url = '#' end + + options[:class] = class_names(css_classes) link_to label, url, options end diff --git a/test/helpers/context_menus_helper_test.rb b/test/helpers/context_menus_helper_test.rb index df9ea3374..20ad333a3 100644 --- a/test/helpers/context_menus_helper_test.rb +++ b/test/helpers/context_menus_helper_test.rb @@ -28,7 +28,7 @@ class ContextMenusHelperTest < Redmine::HelperTest # When :selected is true html = context_menu_link('name', 'url', selected: true, class: 'class-a class-b') - assert_select_in html, 'a.class-a.class-b.icon.disabled.disabled[href=?]', '#' do + assert_select_in html, 'a.class-a.class-b.icon.disabled[href=?]', '#' do assert_select 'svg.icon-svg' end -- 2.39.5