fix(tui): keep overlays centered across resizes (#950)

This commit is contained in:
Nico Bailon 2026-01-26 00:43:16 -08:00 committed by GitHub
parent b1b0fd82b6
commit c565fa9af8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 6 deletions

View file

@ -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