From 93d6f980c009e1ad3f86b386c13ceeae1b0560d8 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Wed, 26 Aug 2026 12:04:15 +0900 Subject: [PATCH] Cannot deselect current user in multi-select user custom field without also deselecting "<< me >>" Do not show the "<< me >>" option when the custom field has multiple values enabled, since it duplicates the current user's own entry with the same value and both options become selected together. Multi-select user custom fields revert to the behavior before #31444; single-value fields are unchanged. Co-Authored-By: Claude Fable 5 --- lib/redmine/field_format.rb | 4 +++- .../lib/redmine/field_format/user_field_format_test.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 46ada2817..b3b2dfa9c 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -876,7 +876,9 @@ module Redmine def possible_values_options(custom_field, object=nil) users = possible_values_records(custom_field, object) options = users.map {|u| [u.name, u.id.to_s]} - options = [["<< #{l(:label_me)} >>", User.current.id]] + options if users.include?(User.current) + if !custom_field.multiple? && users.include?(User.current) + options = [["<< #{l(:label_me)} >>", User.current.id.to_s]] + options + end options end diff --git a/test/unit/lib/redmine/field_format/user_field_format_test.rb b/test/unit/lib/redmine/field_format/user_field_format_test.rb index 9f34d47bb..a056ab4a4 100644 --- a/test/unit/lib/redmine/field_format/user_field_format_test.rb +++ b/test/unit/lib/redmine/field_format/user_field_format_test.rb @@ -84,6 +84,14 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase assert_equal ['<< me >>', 'Dave Lopper', 'John Smith'], field.possible_values_options(project).map(&:first) end + def test_possible_values_options_for_multiple_custom_field_should_not_include_me + User.current = User.find(2) + field = IssueCustomField.new(:field_format => 'user', :multiple => true) + project = Project.find(1) + + assert_equal ['Dave Lopper', 'John Smith'], field.possible_values_options(project).map(&:first) + end + def test_value_from_keyword_should_return_user_id field = IssueCustomField.new(:field_format => 'user') project = Project.find(1) -- 2.55.0