Browse Source

Handle alt+enter in the spoiler input as shortcut for secondary post

Fixes #780
closed-social-glitch-2
Thibaut Girka 6 years ago
committed by ThibG
parent
commit
b0527a4ce7
2 changed files with 9 additions and 1 deletions
  1. +1
    -0
      app/javascript/flavours/glitch/features/composer/index.js
  2. +8
    -1
      app/javascript/flavours/glitch/features/composer/spoiler/index.js

+ 1
- 0
app/javascript/flavours/glitch/features/composer/index.js View File

@ -437,6 +437,7 @@ class Composer extends React.Component {
intl={intl}
onChange={handleChangeSpoiler}
onSubmit={handleSubmit}
onSecondarySubmit={handleSecondarySubmit}
text={spoilerText}
ref={handleRefSpoilerText}
/>

+ 8
- 1
app/javascript/flavours/glitch/features/composer/spoiler/index.js View File

@ -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,
};

Loading…
Cancel
Save