mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 15:03:31 +00:00
fix(tui): keep overlays centered across resizes (#950)
This commit is contained in:
parent
b1b0fd82b6
commit
c565fa9af8
3 changed files with 51 additions and 6 deletions
|
|
@ -154,6 +154,27 @@ const result = await ctx.ui.custom<string | null>(
|
|||
);
|
||||
```
|
||||
|
||||
### Overlay Lifecycle
|
||||
|
||||
Overlay components are disposed when closed. Don't reuse references - create fresh instances:
|
||||
|
||||
```typescript
|
||||
// Wrong - stale reference
|
||||
let menu: MenuComponent;
|
||||
await ctx.ui.custom((_, __, ___, done) => {
|
||||
menu = new MenuComponent(done);
|
||||
return menu;
|
||||
}, { overlay: true });
|
||||
setActiveComponent(menu); // Disposed
|
||||
|
||||
// Correct - re-call to re-show
|
||||
const showMenu = () => ctx.ui.custom((_, __, ___, done) =>
|
||||
new MenuComponent(done), { overlay: true });
|
||||
|
||||
await showMenu(); // First show
|
||||
await showMenu(); // "Back" = just call again
|
||||
```
|
||||
|
||||
See [overlay-qa-tests.ts](../examples/extensions/overlay-qa-tests.ts) for comprehensive examples covering anchors, margins, stacking, responsive visibility, and animation.
|
||||
|
||||
## Built-in Components
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue