diff --git a/app/assets/javascripts/discourse/components/link-to-input.js.es6 b/app/assets/javascripts/discourse/components/link-to-input.js.es6 new file mode 100644 index 00000000000..15c66c41aa2 --- /dev/null +++ b/app/assets/javascripts/discourse/components/link-to-input.js.es6 @@ -0,0 +1,15 @@ +export default Ember.Component.extend({ + showInput: false, + + click() { + this.get("onClick")(); + + Ember.run.schedule("afterRender", () => { + this.$() + .find("input") + .focus(); + }); + + return false; + } +}); diff --git a/app/assets/javascripts/discourse/templates/components/link-to-input.hbs b/app/assets/javascripts/discourse/templates/components/link-to-input.hbs new file mode 100644 index 00000000000..19d1d34bc5d --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/link-to-input.hbs @@ -0,0 +1,5 @@ +{{#if showInput}} + {{yield}} +{{else}} + {{i18n key}} +{{/if}} diff --git a/app/assets/javascripts/discourse/templates/composer.hbs b/app/assets/javascripts/discourse/templates/composer.hbs index 204c01ac729..7fb1cdd3c7d 100644 --- a/app/assets/javascripts/discourse/templates/composer.hbs +++ b/app/assets/javascripts/discourse/templates/composer.hbs @@ -24,11 +24,9 @@ {{/unless}} {{#if canEdit}} - {{#if showEditReason}} - {{text-field autofocus="true" value=editReason tabindex="7" id="edit-reason" maxlength="255" placeholderKey="composer.edit_reason_placeholder"}} - {{else}} - {{i18n 'composer.show_edit_reason'}} - {{/if}} + {{#link-to-input onClick=(action "displayEditReason") showInput=showEditReason key="composer.show_edit_reason" class="display-edit-reason"}} + {{text-field value=editReason tabindex="7" id="edit-reason" maxlength="255" placeholderKey="composer.edit_reason_placeholder"}} + {{/link-to-input}} {{/if}} {{composer-toggles composeState=model.composeState diff --git a/app/assets/stylesheets/common/base/compose.scss b/app/assets/stylesheets/common/base/compose.scss index 86ab628a50c..74951ddf770 100644 --- a/app/assets/stylesheets/common/base/compose.scss +++ b/app/assets/stylesheets/common/base/compose.scss @@ -157,6 +157,10 @@ font-style: italic; } + .display-edit-reason { + display: inline; + } + #edit-reason { margin: 4px; }