Skip to content

A platform for community discussion. Free, open, simple.

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

Joffrey JAFFEUXda1d520d4c66
diff --git a/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6 b/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
index 3fc1065df59..a46f9ff541e 100644
--- a/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
+++ b/app/assets/javascripts/select-kit/components/mini-tag-chooser.js.es6
@@ -45,19 +45,15 @@ export default ComboBox.extend(Tags, {
);
},
- willDestroyElement() {
- this._super(...arguments);
-
- this.$(".selected-name").off("touchend.select-kit pointerup.select-kit");
- },
-
- didInsertElement() {
- this._super(...arguments);
+ click(event) {
+ if (event.target.tagName === "BUTTON") {
+ const $button = $(event.target);
- 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() {},
diff --git a/app/assets/javascripts/select-kit/templates/components/mini-tag-chooser/mini-tag-chooser-header.hbs b/app/assets/javascripts/select-kit/templates/components/mini-tag-chooser/mini-tag-chooser-header.hbs
index 1bd94d922ce..c50e9e371f6 100644
--- a/app/assets/javascripts/select-kit/templates/components/mini-tag-chooser/mini-tag-chooser-header.hbs
+++ b/app/assets/javascripts/select-kit/templates/components/mini-tag-chooser/mini-tag-chooser-header.hbs
@@ -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"}}