mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
cf1e8b2764
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. |
||
---|---|---|
.. | ||
images | ||
javascripts | ||
stylesheets |