We already auto-focus the submit button for modals with no inputs, so enter already works there. With this change, if the modal has text inputs, hitting enter while focused on one of these text inputs will also immediately try to submit.
If we ever add modals that have inputs where enter should do something else (like a multi-line textarea comment box), we'll need to ensure that input captures and does not bubble the enter event, so that it doesn't trigger this.
This code as-is obviously works :) But for future robustness -- would it be easier to add an option enterSubmits: boolean that decides whether to add this submit-on-press-Enter behavior?
Resolves #277.
We already auto-focus the submit button for modals with no inputs, so enter already works there. With this change, if the modal has text inputs, hitting enter while focused on one of these text inputs will also immediately try to submit.
If we ever add modals that have inputs where enter should do something else (like a multi-line textarea comment box), we'll need to ensure that input captures and does not bubble the enter event, so that it doesn't trigger this.