brownplt / code.pyret.org

Website for serving Pyret to folks.
Other
24 stars 44 forks source link

Enter submits modals. #504

Closed asolove closed 3 months ago

asolove commented 6 months ago

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.

blerner commented 3 months ago

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?

ds26gte commented 3 months ago

reviewed w/Joe