DEV: Move topic-list-class transformer to getter (#30301)
Using the (array) helper creates an array instance, passes it to applyValueTransformer, which then allows themes/plugins to mutate it. When the helper is re-computed, the **same array instance** is passed to the transformers again. Any elements added in the last run are still there. This commit moves applyValueTransformer to a getter, so that it's run with a brand new array each time.
This commit is contained in:
parent
41df705188
commit
03bb43f746
|
@ -1,6 +1,6 @@
|
||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import { cached } from "@glimmer/tracking";
|
import { cached } from "@glimmer/tracking";
|
||||||
import { array, hash } from "@ember/helper";
|
import { hash } from "@ember/helper";
|
||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import { eq, or } from "truth-helpers";
|
import { eq, or } from "truth-helpers";
|
||||||
import PluginOutlet from "discourse/components/plugin-outlet";
|
import PluginOutlet from "discourse/components/plugin-outlet";
|
||||||
|
@ -166,13 +166,19 @@ export default class TopicList extends Component {
|
||||||
return lastVisitedTopic;
|
return lastVisitedTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get additionalClasses() {
|
||||||
|
return applyValueTransformer("topic-list-class", [], {
|
||||||
|
topics: this.args.topics,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
{{! template-lint-disable table-groups }}
|
{{! template-lint-disable table-groups }}
|
||||||
<table
|
<table
|
||||||
class={{concatClass
|
class={{concatClass
|
||||||
"topic-list"
|
"topic-list"
|
||||||
(if this.bulkSelectEnabled "sticky-header")
|
(if this.bulkSelectEnabled "sticky-header")
|
||||||
(applyValueTransformer "topic-list-class" (array) (hash topics=@topics))
|
this.additionalClasses
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<caption class="sr-only">{{i18n "sr_topic_list_caption"}}</caption>
|
<caption class="sr-only">{{i18n "sr_topic_list_caption"}}</caption>
|
||||||
|
|
Loading…
Reference in New Issue