As VLAZ notes, "it also works the other way around: if you add a save from the duplicate window, it acts as voting for that duplicate".
The reason this is happening is that the save button is a <button>
and the close modal is a <form>
Per MDN:
- If a button does not specify a form attribute, it's set to the ancestor
<form>
, if any - If the
type
attribute is not specified on the button, it defaults tosubmit
for buttons associated with a form.
So when you click the save button, it submits the closure form, voting to close the question as a duplicate.
I'm not entirely certainAs for why voting for the duplicate closure also saves the target question, thoughthat's because submitting a form triggers its submit button's onClick
. Try hitting enter in the textbox:
<form name="form" method="post">
<input type="text" name="whatever">
<button onClick="alert('Submit button clicked!');">Submit</button>
</form>