We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Render an action that includes multiple variants. For example: :app and :admin.
:app
:admin
request.variant << :app if request.user_agent&.include?("Hotwire Native") request.variant << :admin if Current.admin.present?
Set up a situation where a view component uses the second variant (:admin).
The template for the admin variant should render for admin requests from web and from turbo native.
The default template renders for turbo native admin requests, while the admin template correctly renders for web requests.
Rails version: 7.1.4
Ruby version: 3.3.5
Gem version: 3.18
This issue is caused by an assumption in ViewComponents::base#render_in that there will only be one variant. This is not a correct assumption.
ViewComponents::base#render_in
# For template variants (+phone, +desktop, etc.) @__vc_variant ||= @lookup_context.variants.first
I'm planning to add a test to the work I'm doing for #2128 and resolve the issue by using Rails' logic to pick the preferred variant.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Steps to reproduce
Render an action that includes multiple variants. For example:
:app
and:admin
.Set up a situation where a view component uses the second variant (
:admin
).Expected behavior
The template for the admin variant should render for admin requests from web and from turbo native.
Actual behavior
The default template renders for turbo native admin requests, while the admin template correctly renders for web requests.
System configuration
Rails version:
7.1.4
Ruby version:
3.3.5
Gem version:
3.18
Notes
This issue is caused by an assumption in
ViewComponents::base#render_in
that there will only be one variant. This is not a correct assumption.I'm planning to add a test to the work I'm doing for #2128 and resolve the issue by using Rails' logic to pick the preferred variant.
The text was updated successfully, but these errors were encountered: