Skip to content

Commit 10a5315

Browse files
committed
feat(angular): forward a label input to the drawer element
1 parent 787b9ad commit 10a5315

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

packages/angular/src/lib/components/chat/__tests__/copilot-drawer.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,32 @@ test("copilotDrawerRow renders per-row slot content for each thread", () => {
471471
);
472472
expect(slotEl?.textContent?.trim()).toContain("ROW:Alpha");
473473
});
474+
475+
// ---------------------------------------------------------------------------
476+
// label input forwarding
477+
// ---------------------------------------------------------------------------
478+
479+
/** Host that passes a custom label to the drawer. */
480+
@Component({
481+
selector: "test-host-label",
482+
standalone: true,
483+
imports: [CopilotDrawer],
484+
template: `<copilot-drawer [label]="'Custom'" />`,
485+
})
486+
class HostWithLabelComponent {}
487+
488+
test("label input is forwarded to the <copilotkit-drawer> element label property", () => {
489+
TestBed.resetTestingModule();
490+
TestBed.configureTestingModule({
491+
imports: [HostWithLabelComponent],
492+
});
493+
494+
const fixture = TestBed.createComponent(HostWithLabelComponent);
495+
fixture.detectChanges();
496+
497+
const drawerEl = (fixture.nativeElement as HTMLElement).querySelector(
498+
"copilotkit-drawer",
499+
) as HTMLElement & { label: string };
500+
501+
expect(drawerEl.label).toBe("Custom");
502+
});

packages/angular/src/lib/components/chat/copilot-drawer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export class CopilotDrawer {
140140
alias: "data-testid",
141141
});
142142

143+
/**
144+
* Optional accessible/region + default-header label forwarded to the element's
145+
* `label` property; defaults to the element's own `"Threads"` when unset.
146+
*/
147+
readonly label = input<string | undefined>();
148+
143149
/**
144150
* Optional host override for the thread-select action.
145151
*
@@ -237,6 +243,7 @@ export class CopilotDrawer {
237243
el.activeThreadId = this.activeThreadId();
238244
el.hasMore = this.threads.hasMoreThreads();
239245
el.fetchingMore = this.threads.isFetchingMoreThreads();
246+
if (this.label() !== undefined) el.label = this.label() as string;
240247
});
241248
}
242249

0 commit comments

Comments
 (0)