From a99179d31ff0013987f362ffe15cb3450b29ed08 Mon Sep 17 00:00:00 2001 From: kedama Date: Sun, 10 Jun 2018 23:13:30 +0900 Subject: [PATCH] Control the focus when clicking the "CW" button. (#7776) * Focus to the spoiler text when CW turns on. * Focus back to the textarea when CW turns off. --- .../features/compose/components/compose_form.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index 60485e3c6..83f2f4d34 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -128,12 +128,24 @@ export default class ComposeForm extends ImmutablePureComponent { } else if(prevProps.is_submitting && !this.props.is_submitting) { this.autosuggestTextarea.textarea.focus(); } + + if (this.props.spoiler !== prevProps.spoiler) { + if (this.props.spoiler) { + this.spoilerText.focus(); + } else { + this.autosuggestTextarea.textarea.focus(); + } + } } setAutosuggestTextarea = (c) => { this.autosuggestTextarea = c; } + setSpoilerText = (c) => { + this.spoilerText = c; + } + handleEmojiPick = (data) => { const { text } = this.props; const position = this.autosuggestTextarea.textarea.selectionStart; @@ -164,7 +176,7 @@ export default class ComposeForm extends ImmutablePureComponent {