FIX: focusing input displayed after clicking on a link more reliable

This commit is contained in:
Joffrey JAFFEUX 2018-06-13 10:31:46 +02:00 committed by GitHub
parent 4a9dadb646
commit 4e0c06a0b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 5 deletions

View File

@ -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;
}
});

View File

@ -0,0 +1,5 @@
{{#if showInput}}
{{yield}}
{{else}}
<a href>{{i18n key}}</a>
{{/if}}

View File

@ -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}}
<a {{action "displayEditReason"}} class="display-edit-reason">{{i18n 'composer.show_edit_reason'}}</a>
{{/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}}
</div>
{{composer-toggles composeState=model.composeState

View File

@ -157,6 +157,10 @@
font-style: italic;
}
.display-edit-reason {
display: inline;
}
#edit-reason {
margin: 4px;
}