Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Do not focus disabled fields on the work packages datepicker.

Dombi Attila555513eb19b9
diff --git a/app/components/work_packages/date_picker/date_form_component.rb b/app/components/work_packages/date_picker/date_form_component.rb
index 1b5d54b0337..8537202cb67 100644
--- a/app/components/work_packages/date_picker/date_form_component.rb
+++ b/app/components/work_packages/date_picker/date_form_component.rb
@@ -32,6 +32,9 @@ module WorkPackages
module DatePicker
class DateFormComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
+
+ FOCUSED_CLASS = "op-datepicker-modal--date-field_current"
+
attr_reader :work_package
def initialize(work_package:,
@@ -78,7 +81,7 @@ module WorkPackages
disabled: disabled?(name),
label:,
show_clear_button: show_clear_button?(name),
- classes: "op-datepicker-modal--date-field #{'op-datepicker-modal--date-field_current' if @focused_field == name}",
+ classes: "op-datepicker-modal--date-field #{FOCUSED_CLASS if focused?(name)}",
validation_message: validation_message(name),
type: field_type(name),
placeholder: placeholder(name)
@@ -165,6 +168,10 @@ module WorkPackages
@disabled
end
+ def focused?(name)
+ @focused_field == name && !disabled?(name)
+ end
+
def field_value(name)
errors = @work_package.errors.where(name)
if (user_value = errors.map { |error| error.options[:value] }.find { !it.nil? })
@@ -206,7 +213,7 @@ module WorkPackages
"focus->work-packages--date-picker--preview#onHighlightField",
test_selector: "op-datepicker-modal--#{name.to_s.dasherize}-field" }
- if @focused_field == name && !disabled?(name)
+ if focused?(name)
data[:qa_highlighted] = "true"
data[:focus] = "true"
end