mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 21:03:19 +00:00
Fix DynamicBorder crash when theme not initialized
Make DynamicBorder defensive against undefined theme by checking at render time instead of relying on default parameter closure.
This commit is contained in:
parent
d51770a63d
commit
3ad5a168e7
1 changed files with 4 additions and 2 deletions
|
|
@ -7,8 +7,10 @@ import { theme } from "../theme/theme.js";
|
|||
export class DynamicBorder implements Component {
|
||||
private color: (str: string) => string;
|
||||
|
||||
constructor(color: (str: string) => string = (str) => theme.fg("border", str)) {
|
||||
this.color = color;
|
||||
constructor(color?: (str: string) => string) {
|
||||
// Use provided color function, or default to theme border color
|
||||
// Theme may not be initialized at construction time, so we check at render time
|
||||
this.color = color ?? ((str) => (theme ? theme.fg("border", str) : str));
|
||||
}
|
||||
|
||||
invalidate(): void {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue