From c5a2de99d1040fda8fcdc347cdc38d0b78902085 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 18 Sep 2020 13:50:26 -0400 Subject: [PATCH] FIX: `mouseEnter` is deprecated in newer Ember releases This is the recommended fix via: https://deprecations.emberjs.com/v3.x/#toc_component-mouseenter-leave-move --- .../components/select-kit/select-kit-row.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-row.js b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-row.js index d27397433e4..30ed72ffced 100644 --- a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-row.js +++ b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-row.js @@ -1,6 +1,6 @@ import I18n from "I18n"; import Component from "@ember/component"; -import { computed } from "@ember/object"; +import { computed, action } from "@ember/object"; import { makeArray } from "discourse-common/lib/helpers"; import { guidFor } from "@ember/object/internals"; import UtilsMixin from "select-kit/mixins/utils"; @@ -27,6 +27,18 @@ export default Component.extend(UtilsMixin, { "item.classNames", ], + didInsertElement() { + this._super(...arguments); + this.element.addEventListener("mouseenter", this.handleMouseEnter); + }, + + willDestroyElement() { + this._super(...arguments); + if (this.element) { + this.element.removeEventListener("mouseenter", this.handleMouseEnter); + } + }, + isNone: computed("rowValue", function () { return this.rowValue === this.getValue(this.selectKit.noneItem); }), @@ -91,7 +103,8 @@ export default Component.extend(UtilsMixin, { return this.rowValue === this.value; }), - mouseEnter() { + @action + handleMouseEnter() { if (!this.isDestroying || !this.isDestroyed) { this.selectKit.onHover(this.rowValue, this.item); }