FIX: Cache breadcrumb-item template (#27585)

…to avoid re-evaulation right before destroying.

With `DeferredTrackedSet` we delay both adding and removing elements from the set. That means when you're transitioning between routes, and breadcrumbs change, both old and new breadcrumbs are rendered (briefly, in a first render pass)

And since the arguments for the old breadcrumbs can be (and often are) destroyed - it would blow up the renderer. By caching the template it will reuse it in that first pass.

---

No test because I couldn't figure out a synthetic test setup where you have breadcrumbs in a deeply nested route and where you navigate from that route to one of the parent routes.
This commit is contained in:
Jarek Radosz 2024-06-24 03:00:05 +02:00 committed by GitHub
parent 9adcc4ac91
commit 4af7b4d543
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
import { cached } from "@glimmer/tracking";
import { service } from "@ember/service"; import { service } from "@ember/service";
export default class DBreadcrumbsItem extends Component { export default class DBreadcrumbsItem extends Component {
@ -23,6 +24,7 @@ export default class DBreadcrumbsItem extends Component {
} }
} }
@cached
get templateForContainer() { get templateForContainer() {
// Those are evaluated in a different context than the `@linkClass` // Those are evaluated in a different context than the `@linkClass`
const { label } = this.args; const { label } = this.args;