diff options
author | pluralcafe-docker <git@plural.cafe> | 2018-10-30 05:54:55 +0000 |
---|---|---|
committer | pluralcafe-docker <git@plural.cafe> | 2018-10-30 05:54:55 +0000 |
commit | 431c09bfbe07715a2a88846864179a419d72ab59 (patch) | |
tree | 8b7772f64ea23cdf5e55dda9f92ff57a41adf3a4 /app/javascript/flavours/glitch/features/composer | |
parent | 7c96ee7815c216d6ac3b748d7dd6959376d3914e (diff) | |
parent | 7ec3f6022d5c991bb584c481a29c416e9f1c5438 (diff) |
Merge branch 'glitch'
Diffstat (limited to 'app/javascript/flavours/glitch/features/composer')
4 files changed, 21 insertions, 4 deletions
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/options/dropdown/index.js b/app/javascript/flavours/glitch/features/composer/options/dropdown/index.js index 8cfbac1bb..7817cc964 100644 --- a/app/javascript/flavours/glitch/features/composer/options/dropdown/index.js +++ b/app/javascript/flavours/glitch/features/composer/options/dropdown/index.js @@ -131,7 +131,7 @@ export default class ComposerOptionsDropdown extends React.PureComponent { this.state = { needsModalUpdate: false, open: false, - placement: null, + placement: 'bottom', }; } diff --git a/app/javascript/flavours/glitch/features/composer/spoiler/index.js b/app/javascript/flavours/glitch/features/composer/spoiler/index.js index a7fecbcf5..1c3c962f0 100644 --- a/app/javascript/flavours/glitch/features/composer/spoiler/index.js +++ b/app/javascript/flavours/glitch/features/composer/spoiler/index.js @@ -25,18 +25,31 @@ 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) { this.spoilerText = spoilerText; }, + + // When the escape key is released, we focus the UI. + handleKeyUp ({ key }) { + if (key === 'Escape') { + document.querySelector('.ui').parentElement.focus(); + } + }, }; // The component. @@ -50,7 +63,7 @@ export default class ComposerSpoiler extends React.PureComponent { // Rendering. render () { - const { handleKeyDown, handleRefSpoilerText } = this.handlers; + const { handleKeyDown, handleKeyUp, handleRefSpoilerText } = this.handlers; const { hidden, intl, @@ -69,6 +82,7 @@ export default class ComposerSpoiler extends React.PureComponent { id='glitch.composer.spoiler.input' onChange={onChange} onKeyDown={handleKeyDown} + onKeyUp={handleKeyUp} placeholder={intl.formatMessage(messages.placeholder)} type='text' value={text} @@ -87,5 +101,6 @@ ComposerSpoiler.propTypes = { intl: PropTypes.object.isRequired, onChange: PropTypes.func, onSubmit: PropTypes.func, + onSecondarySubmit: PropTypes.func, text: PropTypes.string, }; diff --git a/app/javascript/flavours/glitch/features/composer/upload_form/item/index.js b/app/javascript/flavours/glitch/features/composer/upload_form/item/index.js index 5addccfb1..93fa4e39e 100644 --- a/app/javascript/flavours/glitch/features/composer/upload_form/item/index.js +++ b/app/javascript/flavours/glitch/features/composer/upload_form/item/index.js @@ -14,6 +14,7 @@ import IconButton from 'flavours/glitch/components/icon_button'; // Utils. import Motion from 'flavours/glitch/util/optional_motion'; import { assignHandlers } from 'flavours/glitch/util/react_helpers'; +import { isUserTouching } from 'flavours/glitch/util/is_mobile'; // Messages. const messages = defineMessages({ @@ -130,7 +131,7 @@ export default class ComposerUploadFormItem extends React.PureComponent { hovered, dirtyDescription, } = this.state; - const active = hovered || focused; + const active = hovered || focused || isUserTouching(); const computedClass = classNames('composer--upload_form--item', { active }); const x = ((focusX / 2) + .5) * 100; const y = ((focusY / -2) + .5) * 100; |