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

Use window.Turbo.fetch if available for turbo-stream requests #74

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

brendon
Copy link
Contributor

@brendon brendon commented Aug 27, 2024

Checks for window.Turbo and if the responseKind is turbo-stream and if both are true then request.js will use window.Turbo.fetch in order to append X-Turbo-Request-Id to the request headers.

The tests don't actually bring in Turbo just as the existing tests don't.

window.Turbo.fetch as at time of writing:
https://github.com/hotwired/turbo/blob/4d65288e913d5a5428e290781313c7909763b133/src/http/fetch.js

Closes: #73

@brendon
Copy link
Contributor Author

brendon commented Aug 30, 2024

Let me know if you need any further testing done, or have any concerns with this change. I've been using it in development and it's working really well. Much cleaner than fake-clicking hidden submit buttons ;)

@marcelolx marcelolx merged commit 421fdc5 into rails:main Aug 30, 2024
1 check passed
@brendon
Copy link
Contributor Author

brendon commented Sep 2, 2024

Hi @marcelolx, just wondering if you'd be able to make a new release with this change in it? :)

@marcelolx
Copy link
Collaborator

@brendon I will once we get to merge #72 as well

@marcelolx
Copy link
Collaborator

@brendon Done

@brendon
Copy link
Contributor Author

brendon commented Sep 3, 2024

Thanks @marcelolx :D

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

Successfully merging this pull request may close these issues.

Adding X-Turbo-Request-Id support
2 participants