From ed0691a071c0d52581b9b927ac7a79d2be5b47a4 Mon Sep 17 00:00:00 2001 From: Sheldon Fernandes Date: Sat, 3 Sep 2016 23:11:56 +0930 Subject: [PATCH] Automatically focus on composer textarea on iOS. closes flarum/core#995 --- framework/core/js/forum/dist/app.js | 12 +++++------- framework/core/js/forum/src/components/Composer.js | 1 + .../core/js/forum/src/components/ReplyPlaceholder.js | 11 ++++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/framework/core/js/forum/dist/app.js b/framework/core/js/forum/dist/app.js index 259474a05..7faa15f73 100644 --- a/framework/core/js/forum/dist/app.js +++ b/framework/core/js/forum/dist/app.js @@ -20163,6 +20163,7 @@ System.register('flarum/components/Composer', ['flarum/Component', 'flarum/utils if (this.isFullScreen()) { this.$().css('top', $(window).scrollTop()); this.showBackdrop(); + this.component.focus(); } } }, { @@ -26249,18 +26250,15 @@ System.register('flarum/components/ReplyPlaceholder', ['flarum/Component', 'flar ); } - function triggerClick(e) { - $(this).trigger('click'); - e.preventDefault(); - } - var reply = function reply() { - DiscussionControls.replyAction.call(_this2.props.discussion, true); + DiscussionControls.replyAction.call(_this2.props.discussion, true).then(function (newComponent) { + newComponent.focus(); + }); }; return m( 'article', - { className: 'Post ReplyPlaceholder', onclick: reply, onmousedown: triggerClick }, + { className: 'Post ReplyPlaceholder', onclick: reply }, m( 'header', { className: 'Post-header' }, diff --git a/framework/core/js/forum/src/components/Composer.js b/framework/core/js/forum/src/components/Composer.js index 85e535c03..f498333e6 100644 --- a/framework/core/js/forum/src/components/Composer.js +++ b/framework/core/js/forum/src/components/Composer.js @@ -362,6 +362,7 @@ class Composer extends Component { if (this.isFullScreen()) { this.$().css('top', $(window).scrollTop()); this.showBackdrop(); + this.component.focus(); } } diff --git a/framework/core/js/forum/src/components/ReplyPlaceholder.js b/framework/core/js/forum/src/components/ReplyPlaceholder.js index 5eeabd4e2..3d277d560 100644 --- a/framework/core/js/forum/src/components/ReplyPlaceholder.js +++ b/framework/core/js/forum/src/components/ReplyPlaceholder.js @@ -31,17 +31,14 @@ export default class ReplyPlaceholder extends Component { ); } - function triggerClick(e) { - $(this).trigger('click'); - e.preventDefault(); - } - const reply = () => { - DiscussionControls.replyAction.call(this.props.discussion, true); + DiscussionControls.replyAction.call(this.props.discussion, true).then(function (newComponent) { + newComponent.focus(); + }); }; return ( -
+
{avatar(app.session.user, {className: 'PostUser-avatar'})}{' '} {app.translator.trans('core.forum.post_stream.reply_placeholder')}