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
When rendering a parent component with multiple child components, the content blocks provided to each child are not displayed as expected. Instead of rendering the <p> content within each child component's container <div>, the child components appear empty in the HTML output. This issue suggests that the blocks passed to each child are not being processed or rendered correctly within the parent-child component structure.
Steps to reproduce
Set up the component structure:
Create an AccordionComponent in app/components/accordion_component.rb to render multiple Accordion::ItemComponent components.
In app/views/application/home.html.erb, render the AccordionComponent with three items, each containing specific content in a block.
<!-- app/views/application/home.html.erb --><%=render(AccordionComponent.new)do |accordion| %> <%accordion.with_itemtitle: :to_classifydo%><p>Items that need to be classified.</p><%end%> <%accordion.with_itemtitle: :classifieddo%><p>Items that have been classified.</p><%end%> <%accordion.with_itemtitle: :rejecteddo%><p>Items that have been rejected.</p><%end%><%end%>
Render the page and check the HTML output:
Run the server and navigate to the view rendering home.html.erb.
Observe the generated HTML output in the browser or inspect it through the page source.
Expected behavior
The content within each Accordion::ItemComponent should be rendered inside the accordion-item<div>. Each item should display the title and the specified content:
<divclass="accordion"><h2>Item to_classify</h2><divclass="accordion-item"><p>Items that need to be classified.</p></div><h2>Item classified</h2><divclass="accordion-item"><p>Items that have been classified.</p></div><h2>Item rejected</h2><divclass="accordion-item"><p>Items that have been rejected.</p></div></div>
Actual behavior
The content inside each Accordion::ItemComponent is missing. The rendered HTML output does not contain the expected <p> content within each accordion-item<div>, resulting in an empty structure:
<body><mainclass="container mx-auto mt-28 px-5 flex"><!-- BEGIN app/views/application/home.html.erb --><!-- BEGIN app/components/accordion_component.html.erb --><divclass"accordion"=""><!-- BEGIN app/components/accordion/item_component.html.erb --><h2>Item to_classify </h2><divclass"accordion-item"=""></div><!-- END app/components/accordion/item_component.html.erb --><!-- BEGIN app/components/accordion/item_component.html.erb --><h2>Item classified </h2><divclass"accordion-item"=""></div><!-- END app/components/accordion/item_component.html.erb --><!-- BEGIN app/components/accordion/item_component.html.erb --><h2>Item rejected </h2><divclass"accordion-item"=""></div><!-- END app/components/accordion/item_component.html.erb --></div><!-- END app/components/accordion_component.html.erb --><!-- END app/views/application/home.html.erb --></main></body>
This indicates that the content passed to each with_item block is not being rendered inside the component.
When rendering a parent component with multiple child components, the content blocks provided to each child are not displayed as expected. Instead of rendering the
<p>
content within each child component's container<div>
, the child components appear empty in the HTML output. This issue suggests that the blocks passed to each child are not being processed or rendered correctly within the parent-child component structure.Steps to reproduce
Set up the component structure:
AccordionComponent
inapp/components/accordion_component.rb
to render multipleAccordion::ItemComponent
components.Define the template for the AccordionComponent:
app/components/accordion_component.html.erb
, iterate over eachitem
to render its content.Create the Accordion::ItemComponent:
Accordion::ItemComponent
with an initializer that accepts atitle
parameter.Define the template for Accordion::ItemComponent:
app/components/accordion/item_component.html.erb
, render the title and the content passed to the item component.Use the component in a view:
app/views/application/home.html.erb
, render theAccordionComponent
with three items, each containing specific content in a block.Render the page and check the HTML output:
home.html.erb
.Expected behavior
The content within each
Accordion::ItemComponent
should be rendered inside theaccordion-item
<div>
. Each item should display the title and the specified content:Actual behavior
The content inside each
Accordion::ItemComponent
is missing. The rendered HTML output does not contain the expected<p>
content within eachaccordion-item
<div>
, resulting in an empty structure:This indicates that the content passed to each
with_item
block is not being rendered inside the component.System configuration
Rails version: 7.2.2
Ruby version: 3.2.2
Gem version: view_component version 3.20
The text was updated successfully, but these errors were encountered: