-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Losing slots after reflex #95
Comments
P.S I can fix the issue by adding data-reflex-permanent tags on a div a wrap the trigger and the sections with it but is that an optimal solution? |
@julianrubisch @joshleblanc any ideas? |
I talked with Omar awhile ago, and I think he found a workaround. Leaving this open because I'm pretty sure it's still a bug. |
After you agreed to whitelist the cable_ready helper on the components I ended up switching the page <%= render(Component.new) do |c|%>
<%= c.with_slot %>
<% end %> But the ViewComponent docs recommend using non-printing tags for slots! |
I see slots are currently still not supported, as ViewComponentReflex ignores any I assume that's because it's problematic to serialize/deserialize them: def safe_instance_variables
instance_variables.reject { |ivar| ivar.start_with?("@__vc") } - unsafe_instance_variables - omitted_from_state
end |
My quick workaround:
Example: # my_component.rb
class MyComponent < ApplicationViewComponent
renders_one :hello_world
def initialize(partial_path:, other_state: {})
@partial_path = partial_path
@other_state = other_state
end
def before_render
super
render partial: @partial_path, locals: { component: self } if @partial_path
end
end - # my_component.html.haml
= hello_world - # show.html.haml
= render MyComponent.new(partial_path: '_partial_component_content', other_state: {}) - # _partial_component_content.html.haml
- component.with_hello_world do
Hello world! |
@Laykou I think that this workaround is very similar to using printing tags to call your slots, both solutions force a recall of the slots block on every refresh pretty much |
In my app I have the following dropdown menu component
when the open function is triggered the menu component is losing all of its slots, am I missing something? I've never encountered this issue before
The text was updated successfully, but these errors were encountered: