Skip to content

Commit 1857983

Browse files
authored
Fix issue preventing expansion and collapse of nav list items with tooltips (#2765)
1 parent e0b2984 commit 1857983

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

.changeset/silver-adults-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/view-components": patch
3+
---
4+
5+
Fix issue preventing expansion and collapse of nav list items with tooltips

app/components/primer/alpha/action_list/item.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<%= render(Primer::BaseComponent.new(tag: :li, **@system_arguments)) do %>
22
<%= render(@form_wrapper) do %>
3+
<%= tooltip %>
34
<%= render(Primer::BaseComponent.new(**@content_arguments)) do %>
45
<% if private_leading_action_icon %>
56
<span class="ActionListItem-visual ActionListItem-action--leading">
@@ -45,7 +46,6 @@
4546
<% end %>
4647
<% end %>
4748
<% end %>
48-
<%= tooltip %>
4949
<% if trailing_action %>
5050
<%= trailing_action %>
5151
<% end %>

previews/primer/alpha/action_list_preview.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,4 +521,4 @@ def long_label_show_tooltip_with_truncate_label(truncate_label: :none)
521521
end
522522
end
523523
end
524-
end
524+
end

previews/primer/beta/nav_list_preview.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def long_label_with_tooltip(truncate_label: :show_tooltip)
139139
component.with_item(
140140
label: "Really really long label that may wrap, truncate, or appear as a tooltip",
141141
truncate_label: truncate_label
142-
)
142+
)
143143
component.with_item(
144144
label: "Really really long label that may wrap, truncate, or appear as a tooltip",
145145
truncate_label: truncate_label
@@ -178,6 +178,20 @@ def long_label_show_tooltip_no_truncate_label
178178
end
179179
end
180180
end
181+
182+
def group_long_label_with_tooltip
183+
render(Primer::Beta::NavList.new) do |list|
184+
list.with_heading(title: "Repository settings")
185+
186+
list.with_item(label: "Really really long label that may wrap, truncate, or appear as a tooltip", truncate_label: :show_tooltip) do |item|
187+
item.with_leading_visual_icon(icon: :"comment-discussion")
188+
189+
item.with_item(label: "Interaction limits", href: "/interaction-limits", selected_by_ids: :interaction_limits)
190+
item.with_item(label: "Code review limits", href: "/review-limits", selected_by_ids: :code_review_limits)
191+
item.with_item(label: "Reported content", href: "/reported-content", selected_by_ids: :reported_content)
192+
end
193+
end
194+
end
181195
end
182196
end
183197
end

test/system/beta/nav_list_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
module Beta
66
class NavListTest < System::TestCase
7+
include Primer::WindowTestHelpers
8+
79
def test_collapses_group
810
visit_preview(:default)
911

@@ -87,6 +89,16 @@ def test_js_api_allows_selecting_item_by_current_location
8789
assert_selector "button[aria-expanded=false]", text: "Moderation"
8890
end
8991

92+
def test_truncate_tooltip_does_not_affect_expanding_group
93+
visit_preview(:group_long_label_with_tooltip)
94+
95+
window.resize(width: 200, height: 200)
96+
refute_selector ".ActionList--subGroup"
97+
98+
find(".ActionListItem--hasSubItem").click
99+
assert_selector ".ActionList--subGroup"
100+
end
101+
90102
private
91103

92104
def select_item_by_id(id)

0 commit comments

Comments
 (0)