discourse/app/assets
Andrei Prigorshnev cf1e8b2764
FEATURE: Accept the flag modal on CTRL + ENTER and CMD + ENTER (#13497)
We want to submit the flag modal on pressing CTRL + ENTER and CMD + ENTER.

Here's how our modals work:

Every modal can be dismissed by pressing ESC. This behaviour can be disabled for a specific modal if we need to.
Every modal can be submitted by pressing ENTER if the cursor wasn't on a text area or a form at the moment of pressing.
Now, the flag modal is actually a one big form and pressing ENTER doesn't submit it. I've added submitting by CTRL+ENTER but at first it was interfering with the basic modal submitting by ENTER. It's a pretty tricky thing to fix because we use the keyup event for submitting by ENTER and we need to use the keydown event for submitting with modifiers (because submitting by CMD+ENTER on Macs doesn't work with keyup).

Eventually, I fixed the problem just by adding a possibility to disable default submitting on ENTER (in the same way as we already have the possibility of disabling dismissing on ESC). Then I disabled default submitting for the flag form and implemented submitting by CTRL+ENTER and CMD+ENTER. This way everything is simple and robust. I did it only for the flag modal but it'll be easy and safe to add the same behaviour to another modal.
2021-06-24 14:13:38 +04:00
..
images DEV: Add SCSS helper to replace asset-uri and image-uri (#12664) 2021-04-12 13:57:39 +10:00
javascripts FEATURE: Accept the flag modal on CTRL + ENTER and CMD + ENTER (#13497) 2021-06-24 14:13:38 +04:00
stylesheets UX: Fix mobile alert spacing (#13506) 2021-06-23 15:21:17 -04:00