Skip to content

Commit

Permalink
Do not overwrite custom data attributes but rather ammend to it
Browse files Browse the repository at this point in the history
  • Loading branch information
HDinger committed Sep 10, 2024
1 parent f6b37f6 commit 4d5d599
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-crews-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openproject/primer-view-components': patch
---

Do not overwrite custom data attributes
18 changes: 6 additions & 12 deletions app/components/primer/open_project/sub_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,16 @@ class SubHeader < Primer::Component
system_arguments[:input_width] ||= :medium

system_arguments[:data] ||= {}
system_arguments[:data][:target]= "sub-header.filterInput"
system_arguments[:data] = merge_data(
system_arguments,
{ data: { target: "sub-header.filterInput" } }
)

system_arguments[:show_clear_button] = true if system_arguments[:show_clear_button].nil?

if system_arguments[:show_clear_button]
system_arguments[:data] = merge_data(
system_arguments,
{
data: {
action: <<~JS
input:sub-header#toggleFilterInputClearButton
focus:sub-header#toggleFilterInputClearButton
JS
}
}
)
system_arguments[:data][:action] ||= ""
system_arguments[:data][:action] += " input:sub-header#toggleFilterInputClearButton focus:sub-header#toggleFilterInputClearButton"
end

@mobile_filter_trigger = Primer::Beta::IconButton.new(icon: system_arguments[:leading_visual][:icon],
Expand Down
6 changes: 2 additions & 4 deletions test/components/primer/open_project/sub_header_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def test_renders_a_clear_button_when_show_clear_button_is_set
assert_selector(".SubHeader")
assert_selector(
".SubHeader-filterInput"\
"[data-action=\"input:sub-header#toggleFilterInputClearButton\n"\
"focus:sub-header#toggleFilterInputClearButton\n\"]"
"[data-action=\" input:sub-header#toggleFilterInputClearButton focus:sub-header#toggleFilterInputClearButton\"]"
)
assert_selector(".FormControl-input-trailingAction[data-action=\"click:primer-text-field#clearContents\"]")
end
Expand All @@ -126,8 +125,7 @@ def test_does_not_render_input_events_when_show_clear_button_is_not_set
assert_selector(".SubHeader-filterInput")
assert_no_selector(
".SubHeader-filterInput"\
"[data-action=\"input:sub-header#toggleFilterInputClearButton\n"\
"focus:sub-header#toggleFilterInputClearButton\n\"]"
"[data-action=\" input:sub-header#toggleFilterInputClearButton focus:sub-header#toggleFilterInputClearButton\"]"
)
assert_no_selector(".FormControl-input-trailingAction[data-action=\"click:primer-text-field#clearContents\"]")
end
Expand Down

0 comments on commit 4d5d599

Please sign in to comment.