You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was also running into the same issue but worryingly my tests were not detecting this.
it "should have a placeholder if no header is defined" do
render_inline(component)
expect(page.find("#detail-page-header")).to have_content("COMING SOON")
end
it "should render the header that is provided" do
render_inline(component.with_header_content("Test Header Content"))
expect(page.find("#detail-page-header")).to have_content("Test Header Content")
expect(page.find("#detail-page-header")).not_to have_content("COMING SOON")
end
The tests pass when defining a def default_header but when I'd load the page the header content was not being rendered, it was falling back to the default_header
<%= render(ProductPageComponent.new(@product)) do |page| %>
<% page.with_header do %>
Something
<% end %>
<% end %>
This renders the content that is defined in default_header unless I make the change suggested by @BillWatts
SlotableDefault
include is not allowing for rendering over the default slot method.Steps to reproduce
SlotableDefault
in a component, add a slot, and then define a default method for that slot.with_[slot_name]
Expected behavior
The slot should be overridden with what is provided by
with_[slot_name]
.Actual behavior
The slot default is rendered instead.
I took the
get_slot
method from the include and added a line from the originalget_slot
method inViewComponent::Slotable
and that seems to have fixed the issue, but not sure if that's entirely the right fix.Willing to submit a PR if someone can point me in the right direction.
Backtrace: None
System configuration
Rails version: 8.0.0
Ruby version: 3.3.0
Gem version: 3.20.0
The text was updated successfully, but these errors were encountered: