Skip to content

Variants not working with XHR Turbo Stream responsesย #2025

@HashNotAdam

Description

@HashNotAdam

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions