Skip to content
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

Variants not working with XHR Turbo Stream responses #2025

Open
HashNotAdam opened this issue May 14, 2024 · 0 comments
Open

Variants not working with XHR Turbo Stream responses #2025

HashNotAdam opened this issue May 14, 2024 · 0 comments

Comments

@HashNotAdam
Copy link

HashNotAdam commented May 14, 2024

Steps to reproduce

  1. Create a component that includes both a standard template and a variant.
  2. Load a page showing the component
  3. Submit a form
  4. In the receiving controller, set the variant, then respond using a turbo stream

Expected behavior

The variant version of the component should be shown

Actual behavior

The default template is rendered

Example repo

This repo includes the recommended HomeController. The root page has 2 buttons, "Request Turbo Drive response" and "Request Turbo Stream response". Both buttons submit a form HomeController#create and in both cases the action sets request.variant = :compact.

The difference, however, is that the Turbo Drive version returns the compact variant, while the Turbo Streams version returns the default template. The page also displays the value of request.variant as well as the name of the variant that was loaded.

First page load

Screenshot 2024-05-14 at 15 19 06 Small

Response from Turbo Drive

Screenshot 2024-05-14 at 15 19 12 Small

Response from Turbo Stream

Screenshot 2024-05-14 at 15 19 16 Small

System configuration

Rails version: 7.1.3.2

Ruby version: 3.2.2

Gem version: 3.11.0

@HashNotAdam HashNotAdam changed the title Variants not working with turbo streams Variants not working with Turbo Streams May 14, 2024
@HashNotAdam HashNotAdam changed the title Variants not working with Turbo Streams Variants not working with XHR Turbo Stream responses May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant