feat(angular): forward a label input to the drawer element

This commit is contained in:
Benjamin Taylor
2026-06-29 15:03:47 -05:00
parent 787b9ad382
commit 10a5315c10
2 changed files with 36 additions and 0 deletions
@@ -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: `<copilot-drawer [label]="'Custom'" />`,
})
class HostWithLabelComponent {}
test("label input is forwarded to the <copilotkit-drawer> 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");
});
@@ -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<string | undefined>();
/**
* 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;
});
}