From 4af7b4d5434dd9a45ebe29f2b2ab3887fbe9b2c2 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 24 Jun 2024 03:00:05 +0200 Subject: [PATCH] FIX: Cache breadcrumb-item template (#27585) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …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. --- .../javascripts/discourse/app/components/d-breadcrumbs-item.gjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/javascripts/discourse/app/components/d-breadcrumbs-item.gjs b/app/assets/javascripts/discourse/app/components/d-breadcrumbs-item.gjs index 42371be304f..0915f1add7d 100644 --- a/app/assets/javascripts/discourse/app/components/d-breadcrumbs-item.gjs +++ b/app/assets/javascripts/discourse/app/components/d-breadcrumbs-item.gjs @@ -1,4 +1,5 @@ import Component from "@glimmer/component"; +import { cached } from "@glimmer/tracking"; import { service } from "@ember/service"; export default class DBreadcrumbsItem extends Component { @@ -23,6 +24,7 @@ export default class DBreadcrumbsItem extends Component { } } + @cached get templateForContainer() { // Those are evaluated in a different context than the `@linkClass` const { label } = this.args;