From 10a5315c105fadc5f020278799bc35488e48d114 Mon Sep 17 00:00:00 2001 From: Benjamin Taylor Date: Mon, 29 Jun 2026 15:03:47 -0500 Subject: [PATCH] feat(angular): forward a label input to the drawer element --- .../chat/__tests__/copilot-drawer.spec.ts | 29 +++++++++++++++++++ .../src/lib/components/chat/copilot-drawer.ts | 7 +++++ 2 files changed, 36 insertions(+) diff --git a/packages/angular/src/lib/components/chat/__tests__/copilot-drawer.spec.ts b/packages/angular/src/lib/components/chat/__tests__/copilot-drawer.spec.ts index bb786c6a42..5f0335e7f1 100644 --- a/packages/angular/src/lib/components/chat/__tests__/copilot-drawer.spec.ts +++ b/packages/angular/src/lib/components/chat/__tests__/copilot-drawer.spec.ts @@ -471,3 +471,32 @@ test("copilotDrawerRow renders per-row slot content for each thread", () => { ); expect(slotEl?.textContent?.trim()).toContain("ROW:Alpha"); }); + +// --------------------------------------------------------------------------- +// label input forwarding +// --------------------------------------------------------------------------- + +/** Host that passes a custom label to the drawer. */ +@Component({ + selector: "test-host-label", + standalone: true, + imports: [CopilotDrawer], + template: ``, +}) +class HostWithLabelComponent {} + +test("label input is forwarded to the element label property", () => { + TestBed.resetTestingModule(); + TestBed.configureTestingModule({ + imports: [HostWithLabelComponent], + }); + + const fixture = TestBed.createComponent(HostWithLabelComponent); + fixture.detectChanges(); + + const drawerEl = (fixture.nativeElement as HTMLElement).querySelector( + "copilotkit-drawer", + ) as HTMLElement & { label: string }; + + expect(drawerEl.label).toBe("Custom"); +}); diff --git a/packages/angular/src/lib/components/chat/copilot-drawer.ts b/packages/angular/src/lib/components/chat/copilot-drawer.ts index ce460a8681..1ad9835ad6 100644 --- a/packages/angular/src/lib/components/chat/copilot-drawer.ts +++ b/packages/angular/src/lib/components/chat/copilot-drawer.ts @@ -140,6 +140,12 @@ export class CopilotDrawer { alias: "data-testid", }); + /** + * Optional accessible/region + default-header label forwarded to the element's + * `label` property; defaults to the element's own `"Threads"` when unset. + */ + readonly label = input(); + /** * Optional host override for the thread-select action. * @@ -237,6 +243,7 @@ export class CopilotDrawer { el.activeThreadId = this.activeThreadId(); el.hasMore = this.threads.hasMoreThreads(); el.fetchingMore = this.threads.isFetchingMoreThreads(); + if (this.label() !== undefined) el.label = this.label() as string; }); }