When the _.pswp_ element is wrapped in a form, every click on the previous, the next and the close button submits this form.
I created a demo by adding a
<form onsubmit="alert('submit')">
around the
<div class="pswp">...</div>
Without having dug deeply into the PhotoSwipe code, I think it should not be necessary to execute the submit action here.
You may add type="button" to PhotoSwipe button elements. Or just don't put .pswp in form, you can add it dynamically anywhere, just before the initialisation.
Ok. Do you want me to send a pull request?
No. If the problem will come up often - I'll implement JS-based solution.
What is the rationale behind not adding type="button"? By default, the type is submit so this will always cause problems when using PhotoSwipe within forms. This seems like an unintended side effect to me that would warrant an issue.
Most helpful comment
What is the rationale behind not adding type="button"? By default, the type is submit so this will always cause problems when using PhotoSwipe within forms. This seems like an unintended side effect to me that would warrant an issue.