0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Tag input UX improvements

Closes #4105

- Turns the tag icon white when input is focused.
- Focuses on the tag inout after deleting a tag.

Credit to @novaugust for a PR to this which is rebased into one single commit
This commit is contained in:
Paul Adam Davis 2014-10-16 10:34:27 +01:00
parent 133aff0626
commit 74d71ed8b8
3 changed files with 19 additions and 19 deletions

View file

@ -616,6 +616,11 @@ body.zen {
color: #fff; color: #fff;
} }
}//.tag-label }//.tag-label
#entry-tags.focused {
.tag-label:before {
color: #fff;
}
}
.publish-bar-inner { .publish-bar-inner {
display: flex; display: flex;

View file

@ -6,15 +6,13 @@
<div class="publish-bar-tags"> <div class="publish-bar-tags">
<div class="tags-wrapper tags"> <div class="tags-wrapper tags">
{{#each controller.tags}} {{#each controller.tags}}
{{#view view.tagView tag=this}} <span class="tag" {{action "deleteTag" this target=view}}>{{name}}</span>
{{view.tag.name}}
{{/view}}
{{/each}} {{/each}}
</div> </div>
</div> </div>
<div class="publish-bar-tags-input"> <div class="publish-bar-tags-input">
<input type="hidden" class="tags-holder" id="tags-holder"> <input type="hidden" class="tags-holder" id="tags-holder">
{{view view.tagInputView class="tag-input" id="tags" value=newTagText}} {{view view.tagInputView class="tag-input js-tag-input" id="tags" value=newTagText}}
<ul class="suggestions dropdown-menu dropdown-triangle-bottom" {{bind-attr style=view.overlayStyles}}> <ul class="suggestions dropdown-menu dropdown-triangle-bottom" {{bind-attr style=view.overlayStyles}}>
{{#each suggestions}} {{#each suggestions}}
{{#view view.suggestionView suggestion=this}} {{#view view.suggestionView suggestion=this}}
@ -22,4 +20,4 @@
{{/view}} {{/view}}
{{/each}} {{/each}}
</ul> </ul>
</div> </div>

View file

@ -2,6 +2,7 @@ var PostTagsInputView = Ember.View.extend({
tagName: 'section', tagName: 'section',
elementId: 'entry-tags', elementId: 'entry-tags',
classNames: 'publish-bar-inner', classNames: 'publish-bar-inner',
classNameBindings: ['hasFocus:focused'],
templateName: 'post-tags-input', templateName: 'post-tags-input',
@ -108,19 +109,6 @@ var PostTagsInputView = Ember.View.extend({
} }
}), }),
tagView: Ember.View.extend({
tagName: 'span',
classNames: 'tag',
tag: null,
click: function () {
this.get('parentView.controller').send('deleteTag', this.get('tag'));
}
}),
suggestionView: Ember.View.extend({ suggestionView: Ember.View.extend({
tagName: 'li', tagName: 'li',
classNameBindings: 'suggestion.selected', classNameBindings: 'suggestion.selected',
@ -139,7 +127,16 @@ var PostTagsInputView = Ember.View.extend({
this.get('parentView.controller').send('addTag', this.get('parentView.controller').send('addTag',
this.get('suggestion.tag')); this.get('suggestion.tag'));
}, },
}) }),
actions: {
deleteTag: function (tag) {
//The view wants to keep focus on the input after a click on a tag
Ember.$('.js-tag-input').focus();
//Make the controller do the actual work
this.get('controller').send('deleteTag', tag);
}
}
}); });
export default PostTagsInputView; export default PostTagsInputView;