]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Add support for submitting media description with ctrl+enter
authorThibG <thib@sitedethib.com>
Mon, 4 Nov 2019 11:59:17 +0000 (12:59 +0100)
committerThibaut Girka <thib@sitedethib.com>
Wed, 6 Nov 2019 13:50:54 +0000 (14:50 +0100)
Port 7488a9e1547733a750160b202942c21f27ffeff2 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/features/ui/components/focal_point_modal.js

index f5ecf77b930642397881015ec85bcf27fe93f778..70e86905f7d885f403ccfb7eb60e22f1e2564690 100644 (file)
@@ -184,6 +184,15 @@ class FocalPointModal extends ImmutablePureComponent {
     this.setState({ description: e.target.value, dirty: true });
   }
 
+  handleKeyDown = (e) => {
+    if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) {
+      e.preventDefault();
+      e.stopPropagation();
+      this.setState({ description: e.target.value, dirty: true });
+      this.handleSubmit();
+    }
+  }
+
   handleSubmit = () => {
     this.props.onSave(this.state.description, this.state.focusX, this.state.focusY);
     this.props.onClose();
@@ -254,6 +263,7 @@ class FocalPointModal extends ImmutablePureComponent {
                 className='setting-text light'
                 value={detecting ? '…' : description}
                 onChange={this.handleChange}
+                onKeyDown={this.handleKeyDown}
                 disabled={detecting}
                 autoFocus
               />