kentcdodds / onewheel-blog

109 stars 26 forks source link

Form Submit on Enter #3

Open kevinfoerster opened 2 years ago

kevinfoerster commented 2 years ago

Hi,

i might have found an issue in your code:

https://github.com/kentcdodds/onewheel-blog/blob/bbc0d2b4c281801e0764559e82097186b348891b/app/routes/posts/admin/%24slug.tsx#L145-L165

when updating the form and hitting enter, the first "submit" button will be pressed, which in this case is delete, which is kind of unexpeced, I guess… is there some way to prevent this?

I just saw this video by Ryan Florence, similar approach, but using a different form.

kentcdodds commented 2 years ago

I think you could fix it by either switching the order or maybe by changing the type to type="button".

kevinfoerster commented 2 years ago

i kind of fixed it by adding the classes flex flex-row-reverse justify-start gap-3 and swapped the buttons, but it is still kind of odd