From 00b7d5d78e2f52dc6bc6c54689e50da976289203 Mon Sep 17 00:00:00 2001 From: Jon Rohan Date: Wed, 30 Aug 2023 13:21:31 -0700 Subject: [PATCH] Update ActionBar::Item to accept an argument for the passed in IconButton (#2223) --- .changeset/sour-parrots-fetch.md | 7 +++++++ app/components/primer/alpha/action_bar.rb | 4 +--- app/components/primer/alpha/action_bar/item.rb | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .changeset/sour-parrots-fetch.md diff --git a/.changeset/sour-parrots-fetch.md b/.changeset/sour-parrots-fetch.md new file mode 100644 index 0000000000..339815fcfc --- /dev/null +++ b/.changeset/sour-parrots-fetch.md @@ -0,0 +1,7 @@ +--- +'@primer/view-components': minor +--- + +Moving the render for the ActionBar::Item from the slot initializer to the call method. + + diff --git a/app/components/primer/alpha/action_bar.rb b/app/components/primer/alpha/action_bar.rb index 0812a4ca68..4842fb7353 100644 --- a/app/components/primer/alpha/action_bar.rb +++ b/app/components/primer/alpha/action_bar.rb @@ -23,9 +23,7 @@ class ActionBar < Primer::Component c.with_leading_visual_icon(icon: icon) end - render(Item.new) do - render(Primer::Beta::IconButton.new(id: item_id, icon: icon, "aria-label": label, size: @size, scheme: :invisible, **system_arguments)) - end + Item.new(Primer::Beta::IconButton.new(id: item_id, icon: icon, "aria-label": label, size: @size, scheme: :invisible, **system_arguments)) }, divider: lambda { @action_menu.with_divider(hidden: true) if @overflow_menu diff --git a/app/components/primer/alpha/action_bar/item.rb b/app/components/primer/alpha/action_bar/item.rb index 57472a2643..28e571d03f 100644 --- a/app/components/primer/alpha/action_bar/item.rb +++ b/app/components/primer/alpha/action_bar/item.rb @@ -7,7 +7,7 @@ module Alpha class ActionBar # ActionBar::Item is an internal component that wraps the items in a div with the `ActionBar-item` class. class Item < Primer::Component - def initialize + def initialize(item_content) @system_arguments = { tag: :div, data: { @@ -15,10 +15,11 @@ def initialize }, classes: "ActionBar-item" } + @item_content = item_content end def call - render(Primer::BaseComponent.new(**@system_arguments)) { content } + render(Primer::BaseComponent.new(**@system_arguments)) { render(@item_content) } end end end