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

[#61165] added input_width argument to pattern input

Eric Schubert957a61679fcf
diff --git a/app/components/work_packages/types/pattern_input.html.erb b/app/components/work_packages/types/pattern_input.html.erb
index 281602778d8..3cbe1035a35 100644
--- a/app/components/work_packages/types/pattern_input.html.erb
+++ b/app/components/work_packages/types/pattern_input.html.erb
@@ -38,56 +38,58 @@ See COPYRIGHT and LICENSE files for more details.
)
) do
%>
- <%= @input.builder.hidden_field(name, value: @value, data: { "pattern-input-target": "formInput" }) %>
+ <%= content_tag(:div, **@field_wrap_arguments) do %>
+ <%= @input.builder.hidden_field(name, value: @value, data: { "pattern-input-target": "formInput" }) %>
- <template data-pattern-input-target="tokenTemplate">
- <%= render(Primer::Beta::Label.new(tag: :span, scheme: :accent, "data-role": :token)) %>
- </template>
+ <template data-pattern-input-target="tokenTemplate">
+ <%= render(Primer::Beta::Label.new(tag: :span, scheme: :accent, "data-role": :token)) %>
+ </template>
- <template data-pattern-input-target="suggestionsHeadingTemplate">
- <%= render(Primer::Alpha::ActionList::Heading.new(title: "__placeholder__", heading_level: 2)) %>
- </template>
+ <template data-pattern-input-target="suggestionsHeadingTemplate">
+ <%= render(Primer::Alpha::ActionList::Heading.new(title: "__placeholder__", heading_level: 2)) %>
+ </template>
- <template data-pattern-input-target="suggestionsDividerTemplate">
- <%= render(Primer::Alpha::ActionList::Divider.new) %>
- </template>
+ <template data-pattern-input-target="suggestionsDividerTemplate">
+ <%= render(Primer::Alpha::ActionList::Divider.new) %>
+ </template>
+
+ <template data-pattern-input-target="suggestionsItemTemplate">
+ <%=
+ render(
+ Primer::Alpha::ActionList::Item.new(
+ list: suggestions_list_component,
+ label: "__placeholder__",
+ role: "menuitem",
+ data: {
+ prop: "__placeholder__",
+ action: "click->pattern-input#suggestions_select"
+ }
+ )
+ )
+ %>
+ </template>
- <template data-pattern-input-target="suggestionsItemTemplate">
<%=
render(
- Primer::Alpha::ActionList::Item.new(
- list: suggestions_list_component,
- label: "__placeholder__",
- role: "menuitem",
+ Primer::BaseComponent.new(
+ tag: :div,
+ contenteditable: true,
+ border: true, border_radius: 2, p: 1, classes: :input,
+ "data-pattern-input-target": "content",
data: {
- prop: "__placeholder__",
- action: "click->pattern-input#suggestions_select"
- }
- )
- )
- %>
- </template>
-
- <%=
- render(
- Primer::BaseComponent.new(
- tag: :div,
- contenteditable: true,
- border: true, border_radius: 2, p: 1, classes: :input,
- "data-pattern-input-target": "content",
- data: {
- action: "keydown->pattern-input#input_keydown
+ action: "keydown->pattern-input#input_keydown
input->pattern-input#input_change
mouseup->pattern-input#input_mouseup
focus->pattern-input#input_focus
blur->pattern-input#input_blur"
- }
+ }
+ )
)
- )
- %>
- <%= render(Primer::BaseComponent.new(tag: :div, box_shadow: :medium, border_radius: 2)) do %>
- <focus-group direction="vertical">
- <%= render(suggestions_list_component) %>
- </focus-group>
+ %>
+ <%= render(Primer::BaseComponent.new(tag: :div, box_shadow: :medium, border_radius: 2)) do %>
+ <focus-group direction="vertical">
+ <%= render(suggestions_list_component) %>
+ </focus-group>
+ <% end %>
<% end %>
<% end %>
diff --git a/app/components/work_packages/types/pattern_input.rb b/app/components/work_packages/types/pattern_input.rb
index c8ef4548fcf..08d75acfb26 100644
--- a/app/components/work_packages/types/pattern_input.rb
+++ b/app/components/work_packages/types/pattern_input.rb
@@ -31,6 +31,8 @@
module WorkPackages
module Types
class PatternInput < Primer::Forms::BaseComponent
+ prepend Primer::OpenProject::Forms::WrappedInput
+
delegate :name, to: :@input
def initialize(input:, value:, suggestions:)
@@ -42,14 +44,14 @@ module WorkPackages
def suggestions_for_stimulus
@suggestions_for_stimulus ||= @suggestions
- .transform_keys { |key| key.to_s.humanize }
- .to_json
+ .transform_keys { |key| key.to_s.humanize }
+ .to_json
end
def suggestions_list_component
@suggestions_list_component ||= Primer::Alpha::ActionList.new(
role: :list,
- classes: "mr-3",
+ mr: 5,
"data-pattern-input-target": "suggestions"
)
end
diff --git a/app/components/work_packages/types/pattern_input.sass b/app/components/work_packages/types/pattern_input.sass
index feafed48d00..ce3e1eb9fb4 100644
--- a/app/components/work_packages/types/pattern_input.sass
+++ b/app/components/work_packages/types/pattern_input.sass
@@ -2,3 +2,8 @@
.input
white-space: pre-wrap
+ &:focus,
+ &:focus-visible
+ border-color: var(--focus-outlineColor) !important
+ box-shadow: inset 0 0 0 1px var(--focus-outlineColor)
+ outline: none
diff --git a/app/forms/work_packages/types/subject_configuration_form.rb b/app/forms/work_packages/types/subject_configuration_form.rb
index 7f6b1697552..6e1f5c4f6d2 100644
--- a/app/forms/work_packages/types/subject_configuration_form.rb
+++ b/app/forms/work_packages/types/subject_configuration_form.rb
@@ -54,6 +54,7 @@ module WorkPackages
toggleable_group.pattern_input(
name: :pattern,
value: model.pattern,
+ input_width: :large,
suggestions: model.suggestions,
label: I18n.t("types.edit.subject_configuration.pattern.label"),
caption: I18n.t("types.edit.subject_configuration.pattern.caption"),