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

🛠️ Component: ButtonComponent supports GET Turbo Streams #1297

Merged
merged 2 commits into from
Apr 3, 2023

Conversation

zspencer
Copy link
Member

@zspencer zspencer commented Apr 2, 2023

It turns out that Turbo only does turbo-streams when PUT/POST/DELETE are the request methods.

If we want to make GET requests use the turbo-stream request type, we need to specify it in the HTML output, i.e. <a href="..." data-turbo-stream=true>

I wasn't sure if this should be default behavior or not, so I leaned towards making it default to not 🤷

- #1187
- https://turbo.hotwired.dev/handbook/streams#streaming-from-http-responses

It turns out that `Turbo` only does turbo-streams when
`PUT`/`POST`/`DELETE` are the request methods.

If we want to make `GET` requests use the `turbo-stream` request type,
we need to specify it in the HTML output, i.e. `<a href="..."
data-turbo-stream=true>`

I wasn't sure if this should be default behavior or not, so I leaned
towards making it default to not 🤷
@zspencer zspencer requested review from anaulin and a team April 2, 2023 23:46
Copy link
Member

@anaulin anaulin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default seems right.

@@ -8,7 +8,8 @@ def initialize(
method: :put,
confirm: nil,
disabled: false,
classes: nil
classes: nil,
turbo_stream: nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be false instead of nil? Doesn't make a functional difference right now, but feels more correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false feels better for sure.

@zspencer zspencer merged commit 4f934f0 into main Apr 3, 2023
@zspencer zspencer deleted the components/button-supports-turbo-streams-on-get branch April 3, 2023 01:23
@zspencer zspencer added 🛠️ infrastructure ci, build, deploy, networking, etc. ✨ feature Reduces Client's Burden or Grants them Benefits labels Apr 3, 2023
@zspencer zspencer added this to the 1.0 - Andromeda milestone May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature Reduces Client's Burden or Grants them Benefits 🛠️ infrastructure ci, build, deploy, networking, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants