# Pressing "Add edit reason" button does not auto-focus into the text field

**URL:** <https://meta.discourse.org/t/pressing-add-edit-reason-button-does-not-auto-focus-into-the-text-field/39140>\
**Category:** Bug\
**Created:** [6 בפברואר,‏ 2016,‏ 9:17am UTC](https://meta.discourse.org/t/pressing-add-edit-reason-button-does-not-auto-focus-into-the-text-field/39140 "2016-02-06T09:17:30Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![GaurangTandon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gaurangtandon/32/52384_2.png) [@GaurangTandon](https://meta.discourse.org/u/GaurangTandon)\
**Post date:** [24 במרץ,‏ 2016,‏ 3:30am UTC](https://meta.discourse.org/t/pressing-add-edit-reason-button-does-not-auto-focus-into-the-text-field/39140/7 "2016-03-24T03:30:00Z")

</div>

Thanks @Mittineague 🙂 I have been looking into the files, and from what I can see, this line in the handlebars file:

```
<a {{action "displayEditReason"}} class="display-edit-reason">{{i18n 'composer.show_edit_reason'}}</a>

```

calls the `displayEditReason` click handler here:

```
displayEditReason() {
  this.set("showEditReason", true);
}

```

and then, since `showEditReason` boolean becomes true, the `if` branch gets executed in this:

```
{{#if showEditReason}}
    <div class="edit-reason-input">
          {{text-field value=editReason tabindex="7" id="edit-reason" maxlength="255" placeholderKey="composer.edit_reason_placeholder"}}
    </div>
{{else}}
    <a {{action "displayEditReason"}} class="display-edit-reason">{{i18n 'composer.show_edit_reason'}}</a
{{/if}}

```

and we see the `.edit-reason-input` field. I then saw this line in the [view](https://github.com/discourse/discourse/blob/eb5cee3150fbd0b2de08d2a93b3959a20e41a691/app/assets/javascripts/discourse/views/composer.js.es6):

```
@observes('composeState', 'composer.action')

```

which makes me feel that something like this:

```plaintext
@observes('showEditReason', function(){
    var input = $(".edit-reason-input input");
    if(input) input.focus();
})

```

might be possible.

Or maybe I again mixed up the view code and the controller code so I will first read the docs 😆

---

_[View the full topic](https://meta.discourse.org/t/pressing-add-edit-reason-button-does-not-auto-focus-into-the-text-field/39140)._
