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

requestSubmit on safari incorrectly sets the submitter property on the SubmitEvent #1071

Open
caleb opened this issue Nov 18, 2023 · 7 comments

Comments

@caleb
Copy link

caleb commented Nov 18, 2023

I've been using Turbo Streams with a custom idiomorph action (though this bug occurs without idiomorph, see the sandbox below for a minimal example) and came across a bug with Turbo & Safari (tested on version 17) that might affect the upcoming refresh feature.

I have a form with multiple submit buttons that have different names, and some stimulus actions that submit the form via requestSubmit(). Clicking a button submits the form to the server and re-renders it with idiomorph., On Safari the requestSubmit form submissions will include the name/value of the previously used submit button.

So, if I submit the form with a submit button that is effect=add_distribution, then net time I submit the form with requestSubmit (regardless of whether I pass a submitter in or not, I tried adding a hidden submit button and specifying that), the previous effect=add_distribution parameter is sent to the server.

Firefox/Chrome work correctly and respect the submitter specified (or not) to requestSubmit

Anyway, for now I'm using the polyfill from Turbo regardless of whether the browser supports requestSubmit natively or not and that fixes the problem.

Just thought I'd bring it to your attention since people will be enjoying less javascript in Turbo 8 with idiomorph and refresh.

Here's a code sandbox showing the issue. If you comment out Turbo, the console shows the correct submitter, but with Turbo enabled, it uses the previous submitter.

@rik
Copy link
Contributor

rik commented Nov 18, 2023

I see you've opened https://bugs.webkit.org/show_bug.cgi?id=265077, that's great!

@caleb
Copy link
Author

caleb commented Nov 18, 2023

Unfortunately I think I jumped the gun on that one, since it seems removing Turbo from being loaded makes Safari work correctly. I've resolved that issue for now, but would be willing to open another one if needed.

I had simply removed using turbo features explicitly, but was obviously still using it since it was being loaded.

@rik
Copy link
Contributor

rik commented Nov 18, 2023

I think this is a dupe of #933. It just has not made it in a release yet.

@caleb
Copy link
Author

caleb commented Nov 18, 2023

Excellent! I can't believe I missed the PR, I searched for existing issues.

I'll give the master branch a try..

@rik
Copy link
Contributor

rik commented Nov 18, 2023

You've got https://github.com/hotwired/dev-builds/tags as well.

@dbil25
Copy link

dbil25 commented Nov 29, 2023

I also had opened this about a month ago but got no attention haha #1050

@caleb
Copy link
Author

caleb commented Nov 29, 2023

I think it will be fixed in the next version of turbo, for now you can grab their polyfill for requestSubmit and use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants