formaat-design / reshaped

Community repository for storing examples, reporting issues and tracking roadmap
https://reshaped.so
97 stars 3 forks source link

Button with type="submit" is not working as expected #235

Closed petewins closed 3 months ago

petewins commented 3 months ago

Describe the bug

Hi, I came across this problem when trying to submit a form using the keyboard

Button with type="submit" does not submit form when using keyboard

To Reproduce

 <form onSubmit={(e) => { e.preventDefault();  alert("form submitted");}} > 
    <Button type="submit">
       Reshaped Submit Button
    </Button>

    <button type="submit">
      HTML Submit Button
    </button>
 </form>
  1. focus on Reshaped button using keyboard
  2. press the enter or space key

https://codesandbox.io/p/devbox/reshaped-button-on-enter-key-does-not-submit-form-8sprjr?file=%2Fapp%2Fpage.tsx%3A14%2C27

Expected behavior Expect the form to submit. It looks like the button's onclick event is firing as expected but not the forms.

I'm not sure what the standards are for type="submit" button but I expect it to behave the same as a native html button

blvdmitry commented 3 months ago

Can you check if it works for you in 2.10.11?

petewins commented 3 months ago

I've updated the codesandbox to 2.10.11 and it still seems to have that issue

blvdmitry commented 3 months ago

Oh yes, you're right. I haven't accounted for the use case when you use Button with a custom onClick that also submits the form natively

blvdmitry commented 3 months ago

Added that part in 2.10.12 as well

petewins commented 3 months ago

Thank you @blvdmitry, tested in 2.10.12 🔥