about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorAsh Levy <ashlea@protonmail.com>2018-07-09 08:47:53 -0400
committerThibG <thib@sitedethib.com>2018-07-10 10:53:22 +0200
commite96a4434c770409af34353b7916f29440a11cf8b (patch)
tree8fbda9d78cb03d67e0aa3558b0911f927cb556db /app
parente6647ccf6d13030a91c7e635526e1e40a059ce31 (diff)
add keybind in composer textarea for secondary submit
Diffstat (limited to 'app')
-rw-r--r--app/javascript/flavours/glitch/features/composer/index.js1
-rw-r--r--app/javascript/flavours/glitch/features/composer/textarea/index.js7
2 files changed, 8 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/composer/index.js b/app/javascript/flavours/glitch/features/composer/index.js
index 21b03be39..1bd1b9347 100644
--- a/app/javascript/flavours/glitch/features/composer/index.js
+++ b/app/javascript/flavours/glitch/features/composer/index.js
@@ -331,6 +331,7 @@ class Composer extends React.Component {
           onPaste={onUpload}
           onPickEmoji={handleEmoji}
           onSubmit={handleSubmit}
+          onSecondarySubmit={handleSecondarySubmit}
           onSuggestionsClearRequested={onClearSuggestions}
           onSuggestionsFetchRequested={onFetchSuggestions}
           onSuggestionSelected={handleSelect}
diff --git a/app/javascript/flavours/glitch/features/composer/textarea/index.js b/app/javascript/flavours/glitch/features/composer/textarea/index.js
index 6c2b8baa2..51d44a83b 100644
--- a/app/javascript/flavours/glitch/features/composer/textarea/index.js
+++ b/app/javascript/flavours/glitch/features/composer/textarea/index.js
@@ -112,6 +112,7 @@ const handlers = {
     const {
       disabled,
       onSubmit,
+      onSecondarySubmit,
       onSuggestionSelected,
       suggestions,
     } = this.props;
@@ -133,6 +134,11 @@ const handlers = {
       onSubmit();
     }
 
+    // Submit the status with secondary visibility on alt + enter.
+    if (onSecondarySubmit && e.keyCode === 13 && e.altKey) {
+      onSecondarySubmit();
+    }
+
     //  Switches over the pressed key.
     switch(e.key) {
 
@@ -294,6 +300,7 @@ ComposerTextarea.propTypes = {
   onPaste: PropTypes.func,
   onPickEmoji: PropTypes.func,
   onSubmit: PropTypes.func,
+  onSecondarySubmit: PropTypes.func,
   onSuggestionsClearRequested: PropTypes.func,
   onSuggestionsFetchRequested: PropTypes.func,
   onSuggestionSelected: PropTypes.func,