flekschas / svelte-simple-modal

A simple, small, and content-agnostic modal for Svelte v3 and v4
https://svelte.dev/repl/b95ce66b0ef34064a34afc5c0249f313
MIT License
422 stars 30 forks source link

Add 'type="button"' to prevent form submission #84

Closed flekschas closed 2 years ago

flekschas commented 2 years ago

Background

See #83

Currently Observed Behavior

When <Modal /> is wrapped by a <form />, clicking on the default close button submits the form

Demo: https://svelte.dev/repl/dd87925ed7a64f08936257414fd63841?version=3.48.0

New Behavior

With the change, the close button has not default behavior and, thus, will not submit the form

Demo: https://svelte.dev/repl/7e3efb8138314975ad246a3a575a450b?version=3.48.0

flekschas commented 2 years ago

@jnysteen Can you confirm that this change fixes the problem for you? In my tests, the fix worked and it seem to be good practice to set the button type in general.

jnysteen commented 2 years ago

Yes, this seems to fix it - thanks!