From b0527a4ce702bfab8c53b31917038e7463b9d39c Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sun, 14 Oct 2018 11:38:38 +0200 Subject: Handle alt+enter in the spoiler input as shortcut for secondary post Fixes #780 --- app/javascript/flavours/glitch/features/composer/index.js | 1 + .../flavours/glitch/features/composer/spoiler/index.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/features/composer/index.js b/app/javascript/flavours/glitch/features/composer/index.js index 257797047..029b11a36 100644 --- a/app/javascript/flavours/glitch/features/composer/index.js +++ b/app/javascript/flavours/glitch/features/composer/index.js @@ -437,6 +437,7 @@ class Composer extends React.Component { intl={intl} onChange={handleChangeSpoiler} onSubmit={handleSubmit} + onSecondarySubmit={handleSecondarySubmit} text={spoilerText} ref={handleRefSpoilerText} /> diff --git a/app/javascript/flavours/glitch/features/composer/spoiler/index.js b/app/javascript/flavours/glitch/features/composer/spoiler/index.js index a7fecbcf5..152e64d7a 100644 --- a/app/javascript/flavours/glitch/features/composer/spoiler/index.js +++ b/app/javascript/flavours/glitch/features/composer/spoiler/index.js @@ -25,13 +25,19 @@ const handlers = { ctrlKey, keyCode, metaKey, + altKey, }) { - const { onSubmit } = this.props; + const { onSubmit, onSecondarySubmit } = this.props; // We submit the status on control/meta + enter. if (onSubmit && keyCode === 13 && (ctrlKey || metaKey)) { onSubmit(); } + + // Submit the status with secondary visibility on alt + enter. + if (onSecondarySubmit && keyCode === 13 && altKey) { + onSecondarySubmit(); + } }, handleRefSpoilerText (spoilerText) { @@ -87,5 +93,6 @@ ComposerSpoiler.propTypes = { intl: PropTypes.object.isRequired, onChange: PropTypes.func, onSubmit: PropTypes.func, + onSecondarySubmit: PropTypes.func, text: PropTypes.string, }; -- cgit