FIX: simplifies mini tag chooser events handling (#6252)

This commit is contained in:
Joffrey JAFFEUX 2018-08-09 14:23:28 +02:00 committed by GitHub
parent bfcf8ed61b
commit da1d520d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 45 deletions

View File

@ -45,19 +45,15 @@ export default ComboBox.extend(Tags, {
);
},
willDestroyElement() {
this._super(...arguments);
click(event) {
if (event.target.tagName === "BUTTON") {
const $button = $(event.target);
this.$(".selected-name").off("touchend.select-kit pointerup.select-kit");
},
didInsertElement() {
this._super(...arguments);
this.$(".selected-name").on(
"touchend.select-kit pointerup.select-kit",
() => this.focusFilterOrHeader()
);
if ($button.hasClass("selected-tag")) {
this._destroyEvent(event);
this.destroyTags(this.computeContentItem($button.attr("data-value")));
}
}
},
@computed("hasReachedMaximum")
@ -74,37 +70,6 @@ export default ComboBox.extend(Tags, {
return computedContent;
},
didRender() {
this._super();
this.$(".select-kit-body").on(
"click.mini-tag-chooser",
".selected-tag",
event => {
event.stopImmediatePropagation();
this.destroyTags(
this.computeContentItem($(event.target).attr("data-value"))
);
}
);
this.$(".select-kit-header").on(
"focus.mini-tag-chooser",
".selected-name",
event => {
event.stopImmediatePropagation();
this.focus(event);
}
);
},
willDestroyElement() {
this._super();
this.$(".select-kit-body").off("click.mini-tag-chooser");
this.$(".select-kit-header").off("focus.mini-tag-chooser");
},
// we are directly mutatings tags to define the current selection
mutateValue() {},

View File

@ -1,3 +1,2 @@
{{input class="selected-name" value=label readonly="readonly" tabindex="-1"}}
<span class="selected-name">{{label}}</span>
{{d-icon caretIcon class="caret-icon"}}