Project

General

Profile

Actions

Patch #40210

closed

Remove overrides that inserts a non-breaking space (nbsp) to empty option elements

Added by Mizuki ISHIKAWA 11 months ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

In Redmine forms, a problem occurs where the "blank" option does not appear in select box fields (e.g., Version or Category). The blank option is visible when the default value is blank, such as in the new issue form. However, if a non-blank value is selected, saved, and then the edit issue form is reloaded, the blank option is missing from the select box.

Example 1: After changing the category value from blank to another value and registering the issue, when you attempt to change the category back to blank in the edit form, the blank option is missing from the category select box.

Example 2: Similarly, when creating a new issue with a default version set in the project settings, if you try to set the version back to blank, the blank option is missing from the version select box.

Despite the f.selectbox being configured with include_blank: true, it does not seem to function properly. This issue does not occur in the Redmine 5.1-stable version and is observed only in the trunk version.


Files


Related issues

Related to Redmine - Feature #36320: Migrate to Rails 7.2ClosedMarius BĂLTEANU

Actions
Related to Redmine - Defect #25337: Redmine patch for Rails breaks functionality of select_tagClosed

Actions
Actions #1

Updated by Go MAEDA 11 months ago

I have confirmed the issue. In the following screenshot, you cannot set the assignee field to blank.

Actions #2

Updated by Mizuki ISHIKAWA 11 months ago

It appears to be affected by the changes made to config/initializers/10-patches.rb in r22488 ( https://github.com/redmine/redmine/commit/7b911245d31509da8fa656bbedc37213d3148897?diff=unified&w=0#diff-3df1b8f50fcd1f2fcef72d0bae0d030cc1c5dad45c63acbd1722b4c6fa98c7f6R55-L83 ) .
The problem can be fixed by making the following change.

diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb
index 1d932eb1f..6024e8c8d 100644
--- a/config/initializers/10-patches.rb
+++ b/config/initializers/10-patches.rb
@@ -41,7 +41,7 @@ module ActionView
       SelectRenderer.prepend(Module.new do
         def add_options(option_tags, options, value = nil)
           if options.delete(:include_blank)
-            options[:prompt] = ' '.html_safe
+            options[:include_blank] = ' '.html_safe
           end
           super
         end
Actions #3

Updated by Go MAEDA 11 months ago

Actions #4

Updated by Go MAEDA 11 months ago

I am beginning to question the necessity of the code that inserts a non-breaking space (nbsp) to empty option elements.

The code was added in r12237. The purpose of the change was to fix HTML5 validation failures pointed out in #15191. However, I have not found any evidence that empty option elements violate HTML5 standards.

I tested the following HTML, which contains an empty option element (<option value="" label=" "></option>), using the Nu Html Checker by W3C and the test passed without any errors.

<!DOCTYPE html>
<html lang="en">
<head>
<title>test</title>
</head>
<body>
<select name="issue[category_id]" id="issue_category_id"><option value="" label=" "></option>
<option selected="selected" value="1">Printing</option>
<option value="2">Recipes</option></select>
</body>
</html>

Additionally, I checked the MDN documentation and still could not find any mention of an empty option element being prohibited.

I believe the Rails team should have improved the form helper to insert nbsp when :include_blank is passed if it violates HTML5 standards, but such enhancement has not occured even 10 years after r12237 was committed. In my opinion, this suggests that the Rails team does not consider empty option elements are disallowed.

Based on the above, I propose to delete the code to insert nbsp to every blank option element.

Actions #5

Updated by Mizuki ISHIKAWA 11 months ago

Based on the above, I propose to delete the code to insert nbsp to every blank option element.

I'm in favor of it.

Actions #6

Updated by Marius BĂLTEANU 11 months ago

  • Assignee set to Marius BĂLTEANU
Actions #7

Updated by Marius BĂLTEANU 11 months ago

  • Tracker changed from Defect to Patch
  • Subject changed from Blank option not included in selectbox options when a non-blank value is selected to Remove overrides that inserts a non-breaking space (nbsp) to empty option elements
  • Category set to Code cleanup/refactoring
  • Status changed from Confirmed to Resolved
  • Target version set to 6.0.0
Actions #8

Updated by Go MAEDA 11 months ago

  • Related to Defect #25337: Redmine patch for Rails breaks functionality of select_tag added
Actions #9

Updated by Marius BĂLTEANU 11 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF