mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: makes highlighting last viewed topic more resilient (#8624)
`highlight` was called from `didInsertElement` which technically doesn't ensure the list is rendered. By wrapping the highlighting code in `afterRender` we ensure it works more consistently.
This commit is contained in:
parent
473e39f4a4
commit
6fa5725292
@ -1,6 +1,7 @@
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { alias } from "@ember/object/computed";
|
||||
import Component from "@ember/component";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
||||
import { findRawTemplate } from "discourse/lib/raw-templates";
|
||||
@ -197,12 +198,18 @@ export const ListItemDefaults = {
|
||||
navigateToTopic,
|
||||
|
||||
highlight(opts = { isLastViewedTopic: false }) {
|
||||
const $topic = $(this.element);
|
||||
$topic
|
||||
.addClass("highlighted")
|
||||
.attr("data-islastviewedtopic", opts.isLastViewedTopic);
|
||||
schedule("afterRender", () => {
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
$topic.on("animationend", () => $topic.removeClass("highlighted"));
|
||||
const $topic = $(this.element);
|
||||
$topic
|
||||
.addClass("highlighted")
|
||||
.attr("data-islastviewedtopic", opts.isLastViewedTopic);
|
||||
|
||||
$topic.on("animationend", () => $topic.removeClass("highlighted"));
|
||||
});
|
||||
},
|
||||
|
||||
_highlightIfNeeded: on("didInsertElement", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user