fix: serialize forms submitted by <button>
A more modern approach using form submit event’s ‘submitter’ property.
https://caniuse.com/mdn-api_submitevent_submitter
Also requires changes to reblocks-ui
Why this is better approach (aside that it is more "modern")?
Also, I see at https://caniuse.com/mdn-api_submitevent_submitter that Internet Explorer does not support "submitter" even in the latest version. This could be a problem for some users.
Why this is better approach (aside that it is more "modern")?
This patch a fix for forms containing <button>s. Those aren't caught by the old code.
Another thing this catches is non-click submission events, e.g. if you're in an field and press Enter, a default submit button is selected and used as the submission. A regular post form catches that.
Also, I see at https://caniuse.com/mdn-api_submitevent_submitter that Internet Explorer does not support "submitter" even in the latest version. This could be a problem for some users.
Internet explorer is obsolete and unsupported even by MS now I think. https://en.wikipedia.org/wiki/Internet_Explorer says development stopped in 2016 and all support ended 2022.
Aha! I'll have to play with this first. Thank you for the PR.
@hraban I've build this simple demo using the latest version of Reblocks and Reblocks-ui:
https://gist.github.com/svetlyak40wt/47df0712195ca49c1ae96c62294c4bd3
And both button and input :type button works perfectly with keyboard events.
Could you please update this example to make it possible to reproduce the problem which can be solved by "submitter"?
The point is getting the value of the button. Try this one https://github.com/40ants/reblocks-websocket/issues/4 but substitute the <input name="x" value="y" type="submit"> with <button name="x" value="y">y</button>.
@hraban sorry for a long delay with replies, I'm having some troubles with health and have to solve them asap.
However today I've tested your changes from this PR and from your PR to rebocks-ui, on my example form and noticed that form is submitted as usual POST request with full page reload instead of Ajax request:
Do you have any ideas how to fix this behaviour?
@svetlyak40wt if you also use reblocks-ui you need this PR : https://github.com/40ants/reblocks-ui/pull/10
Good luck with your health btw!! Best wishes.
@svetlyak40wt if you also use reblocks-ui you need this PR : 40ants/reblocks-ui#10
Hmm, I've used both PRs. However now after the full application restart it works as Ajax requests. Probably some code was in conflict when I've switched branches and did quickload in my previous attempt.
Merged as part of the https://github.com/40ants/reblocks/pull/62