Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/ui/src/v2/components/ct-list/ct-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export class CTList extends BaseElement {
// Private state for managing editing
@state()
private _editing: Cell<ListItem> | null = null;

// Subscription cleanup function
private _unsubscribe: (() => void) | null = null;

constructor() {
super();
Expand Down Expand Up @@ -322,6 +325,31 @@ export class CTList extends BaseElement {
// Lifecycle methods for Cell binding management
override updated(changedProperties: Map<string, any>) {
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 {
Expand Down