mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Merge pull request #5772 from kevinansfield/minor-tag-input-updates
Don't show selectize dropdown when input field is blank
This commit is contained in:
commit
40f82b6204
4 changed files with 22 additions and 20 deletions
|
@ -124,23 +124,6 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
onBlur: function () {
|
onBlur: function () {
|
||||||
this._resetKeymasterScope();
|
this._resetKeymasterScope();
|
||||||
},
|
|
||||||
|
|
||||||
// hacky method of disabling the dropdown until a user has typed something
|
|
||||||
// TODO: move into a selectize plugin
|
|
||||||
onInit: function () {
|
|
||||||
var selectize = this.get('_selectize');
|
|
||||||
selectize.on('dropdown_open', function () {
|
|
||||||
if (Ember.isBlank(selectize.$control_input.val())) {
|
|
||||||
selectize.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onUpdateFilter: function (filter) {
|
|
||||||
if (Ember.isBlank(filter)) {
|
|
||||||
this.get('_selectize').close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,26 @@ import EmberSelectizeComponent from 'ember-cli-selectize/components/ember-select
|
||||||
|
|
||||||
export default EmberSelectizeComponent.extend({
|
export default EmberSelectizeComponent.extend({
|
||||||
|
|
||||||
|
_dontOpenWhenBlank: Ember.on('didInsertElement', function () {
|
||||||
|
var openOnFocus = this.get('openOnFocus');
|
||||||
|
|
||||||
|
if (!openOnFocus) {
|
||||||
|
Ember.run.next(this, function () {
|
||||||
|
var selectize = this._selectize;
|
||||||
|
selectize.on('dropdown_open', function () {
|
||||||
|
if (Ember.isBlank(selectize.$control_input.val())) {
|
||||||
|
selectize.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
selectize.on('type', function (filter) {
|
||||||
|
if (Ember.isBlank(filter)) {
|
||||||
|
selectize.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event callback that is triggered when user creates a tag
|
* Event callback that is triggered when user creates a tag
|
||||||
* - modified to pass the caret position to the action
|
* - modified to pass the caret position to the action
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
optionGroupPath="content.category"
|
optionGroupPath="content.category"
|
||||||
openOnFocus=false
|
openOnFocus=false
|
||||||
maxItems="1"
|
maxItems="1"
|
||||||
on-init="onInit"
|
|
||||||
on-focus="onFocus"
|
on-focus="onFocus"
|
||||||
on-blur="onBlur"
|
on-blur="onBlur"
|
||||||
select-item="openSelected"
|
select-item="openSelected"}}
|
||||||
update-filter="onUpdateFilter"}}
|
|
||||||
<button class="gh-nav-search-button" {{action "focusInput"}}><i class="icon-search"></i><span class="sr-only">Search</span></button>
|
<button class="gh-nav-search-button" {{action "focusInput"}}><i class="icon-search"></i><span class="sr-only">Search</span></button>
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
content=availableTags
|
content=availableTags
|
||||||
optionValuePath="content.uuid"
|
optionValuePath="content.uuid"
|
||||||
optionLabelPath="content.name"
|
optionLabelPath="content.name"
|
||||||
|
openOnFocus=false
|
||||||
create-item="addTag"
|
create-item="addTag"
|
||||||
remove-item="removeTag"}}
|
remove-item="removeTag"}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue