REFACTOR: ensures later is correctly canceled (#9796)
This commit is contained in:
parent
9482ddff73
commit
48ed1b40cf
|
@ -1,7 +1,8 @@
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { not } from "@ember/object/computed";
|
import { not } from "@ember/object/computed";
|
||||||
import { later } from "@ember/runloop";
|
import { action } from "@ember/object";
|
||||||
|
import { later, cancel } from "@ember/runloop";
|
||||||
import { buildCategoryPanel } from "discourse/components/edit-category-panel";
|
import { buildCategoryPanel } from "discourse/components/edit-category-panel";
|
||||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
|
@ -19,6 +20,12 @@ export default buildCategoryPanel("general", {
|
||||||
this._focusCategoryName();
|
this._focusCategoryName();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
willDestroyElement() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
this._laterFocus && cancel(this._laterFocus);
|
||||||
|
},
|
||||||
|
|
||||||
canSelectParentCategory: not("category.isUncategorizedCategory"),
|
canSelectParentCategory: not("category.isUncategorizedCategory"),
|
||||||
uncategorizedSiteSettingLink: Discourse.getURL(
|
uncategorizedSiteSettingLink: Discourse.getURL(
|
||||||
"/admin/site_settings/category/all_results?filter=allow_uncategorized_topics"
|
"/admin/site_settings/category/all_results?filter=allow_uncategorized_topics"
|
||||||
|
@ -103,19 +110,16 @@ export default buildCategoryPanel("general", {
|
||||||
return !isUncategorizedCategory && categoryId;
|
return !isUncategorizedCategory && categoryId;
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
@action
|
||||||
showCategoryTopic() {
|
showCategoryTopic() {
|
||||||
window.open(this.get("category.topic_url"), "_blank").focus();
|
window.open(this.get("category.topic_url"), "_blank").focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_focusCategoryName() {
|
_focusCategoryName() {
|
||||||
later(() => {
|
this._laterFocus = later(() => {
|
||||||
if (this.element && !this.isDestroying && !this.isDestroyed) {
|
|
||||||
const categoryName = this.element.querySelector(".category-name");
|
const categoryName = this.element.querySelector(".category-name");
|
||||||
categoryName && categoryName.focus();
|
categoryName && categoryName.focus();
|
||||||
}
|
|
||||||
}, 25);
|
}, 25);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue