Skip to content

Commit

Permalink
Fix issue preventing expansion and collapse of nav list items with to…
Browse files Browse the repository at this point in the history
…oltips (#2765)
  • Loading branch information
camertron authored Apr 10, 2024
1 parent e0b2984 commit 1857983
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-adults-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Fix issue preventing expansion and collapse of nav list items with tooltips
2 changes: 1 addition & 1 deletion app/components/primer/alpha/action_list/item.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<%= render(Primer::BaseComponent.new(tag: :li, **@system_arguments)) do %>
<%= render(@form_wrapper) do %>
<%= tooltip %>
<%= render(Primer::BaseComponent.new(**@content_arguments)) do %>
<% if private_leading_action_icon %>
<span class="ActionListItem-visual ActionListItem-action--leading">
Expand Down Expand Up @@ -45,7 +46,6 @@
<% end %>
<% end %>
<% end %>
<%= tooltip %>
<% if trailing_action %>
<%= trailing_action %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion previews/primer/alpha/action_list_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,4 @@ def long_label_show_tooltip_with_truncate_label(truncate_label: :none)
end
end
end
end
end
16 changes: 15 additions & 1 deletion previews/primer/beta/nav_list_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def long_label_with_tooltip(truncate_label: :show_tooltip)
component.with_item(
label: "Really really long label that may wrap, truncate, or appear as a tooltip",
truncate_label: truncate_label
)
)
component.with_item(
label: "Really really long label that may wrap, truncate, or appear as a tooltip",
truncate_label: truncate_label
Expand Down Expand Up @@ -178,6 +178,20 @@ def long_label_show_tooltip_no_truncate_label
end
end
end

def group_long_label_with_tooltip
render(Primer::Beta::NavList.new) do |list|
list.with_heading(title: "Repository settings")

list.with_item(label: "Really really long label that may wrap, truncate, or appear as a tooltip", truncate_label: :show_tooltip) do |item|
item.with_leading_visual_icon(icon: :"comment-discussion")

item.with_item(label: "Interaction limits", href: "/interaction-limits", selected_by_ids: :interaction_limits)
item.with_item(label: "Code review limits", href: "/review-limits", selected_by_ids: :code_review_limits)
item.with_item(label: "Reported content", href: "/reported-content", selected_by_ids: :reported_content)
end
end
end
end
end
end
12 changes: 12 additions & 0 deletions test/system/beta/nav_list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

module Beta
class NavListTest < System::TestCase
include Primer::WindowTestHelpers

def test_collapses_group
visit_preview(:default)

Expand Down Expand Up @@ -87,6 +89,16 @@ def test_js_api_allows_selecting_item_by_current_location
assert_selector "button[aria-expanded=false]", text: "Moderation"
end

def test_truncate_tooltip_does_not_affect_expanding_group
visit_preview(:group_long_label_with_tooltip)

window.resize(width: 200, height: 200)
refute_selector ".ActionList--subGroup"

find(".ActionListItem--hasSubItem").click
assert_selector ".ActionList--subGroup"
end

private

def select_item_by_id(id)
Expand Down

0 comments on commit 1857983

Please sign in to comment.