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/glitch/features/composer') 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 From 13c3fa8d36c049395fd817056f378829f81edeb3 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sat, 20 Oct 2018 13:17:02 +0200 Subject: Focus the UI when pressing Escape in the CW field --- .../flavours/glitch/features/composer/spoiler/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/javascript/flavours/glitch/features/composer') diff --git a/app/javascript/flavours/glitch/features/composer/spoiler/index.js b/app/javascript/flavours/glitch/features/composer/spoiler/index.js index 152e64d7a..1c3c962f0 100644 --- a/app/javascript/flavours/glitch/features/composer/spoiler/index.js +++ b/app/javascript/flavours/glitch/features/composer/spoiler/index.js @@ -43,6 +43,13 @@ const handlers = { 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. @@ -56,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, @@ -75,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} -- cgit From 323ae1403a7aef884d617decac36963afcc7fc70 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Mon, 22 Oct 2018 18:41:34 +0200 Subject: [Glitch] fix: initial state of PrivacyDropdown is should not be null Port bebe8ec887ba67c51353e09d7758819b117bf62d to glitch-soc --- .../flavours/glitch/features/composer/options/dropdown/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript/flavours/glitch/features/composer') 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', }; } -- cgit From 8f4fab65a1ebc8296cb398fb3ce4144dcf264f35 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 26 Oct 2018 16:46:53 +0200 Subject: Do not rely on hover for upload form options if touch is used --- .../flavours/glitch/features/composer/upload_form/item/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/javascript/flavours/glitch/features/composer') 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; -- cgit