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

handle line break only long text field in project list

ulferts63e6918ae4cf
diff --git a/app/components/open_project/common/attribute_component.rb b/app/components/open_project/common/attribute_component.rb
index 12d1584a7b6..e77a2f9892b 100644
--- a/app/components/open_project/common/attribute_component.rb
+++ b/app/components/open_project/common/attribute_component.rb
@@ -57,7 +57,7 @@ module OpenProject
end
def display_expand_button_value
- multi_type? || text_ast.xpath('html/body').children.length > 1 ? :block : :none
+ multi_type? || body_children.length > 1 ? :block : :none
end
def text_color
@@ -67,18 +67,26 @@ module OpenProject
private
def first_paragraph
- @first_paragraph ||= text_ast
- .xpath('html/body')
- .children
- .first
- .inner_html
- .html_safe # rubocop:disable Rails/OutputSafety
+ @first_paragraph ||= if body_children.any?
+ body_children
+ .first
+ .inner_html
+ .html_safe # rubocop:disable Rails/OutputSafety
+ else
+ ''
+ end
end
def text_ast
@text_ast ||= Nokogiri::HTML(full_text)
end
+ def body_children
+ text_ast
+ .xpath('html/body')
+ .children
+ end
+
def multi_type?
first_paragraph.include?('figure') || first_paragraph.include?('macro')
end