From 247c445af3fcbb2ae40036e209617a6a4a0d66cf Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:28:29 +1000 Subject: [PATCH] Fix ct-list re-rendering --- .../ui/src/v2/components/ct-list/ct-list.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/ui/src/v2/components/ct-list/ct-list.ts b/packages/ui/src/v2/components/ct-list/ct-list.ts index a404d10e60..f0f97d3766 100644 --- a/packages/ui/src/v2/components/ct-list/ct-list.ts +++ b/packages/ui/src/v2/components/ct-list/ct-list.ts @@ -96,6 +96,9 @@ export class CTList extends BaseElement { // Private state for managing editing @state() private _editing: Cell | null = null; + + // Subscription cleanup function + private _unsubscribe: (() => void) | null = null; constructor() { super(); @@ -322,6 +325,31 @@ export class CTList extends BaseElement { // Lifecycle methods for Cell binding management override updated(changedProperties: Map) { super.updated(changedProperties); + + // Handle value changes + if (changedProperties.has('value')) { + // Clean up previous subscription + if (this._unsubscribe) { + this._unsubscribe(); + this._unsubscribe = null; + } + + // Subscribe to new Cell if it exists + if (this.value && isCell(this.value)) { + this._unsubscribe = this.value.sink(() => { + this.requestUpdate(); + }); + } + } + } + + override disconnectedCallback() { + super.disconnectedCallback(); + // Clean up subscription + if (this._unsubscribe) { + this._unsubscribe(); + this._unsubscribe = null; + } } private addItem(title: string): void {