From 58c19ac07cb35d95ec2d58b7fb57d535907be555 Mon Sep 17 00:00:00 2001 From: Ash Levy Date: Mon, 9 Jul 2018 08:47:53 -0400 Subject: [PATCH] add keybind in composer textarea for secondary submit --- app/javascript/flavours/glitch/features/composer/index.js | 1 + .../flavours/glitch/features/composer/textarea/index.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/app/javascript/flavours/glitch/features/composer/index.js b/app/javascript/flavours/glitch/features/composer/index.js index 21b03be390..1bd1b93476 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 6c2b8baa2e..51d44a83be 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,