xonecas.io
70160
Ce

cel-tui / commit 8d93257

refactor(core): remove dead containerScrolls WeakMap in paint.ts

The containerScrolls WeakMap and getContainerScroll function were
vestigial from before the path-keyed uncontrolledScrollOffsets Map
was introduced in cel.ts. The WeakMap was never written to, so
getContainerScroll always returned 0. Replaced the single call site
with ?? 0.

Also documented two spec audit findings in TODO.md:
- Key events leaking through layers
- space-between + gap double-spacing

xonecas2026-04-04 8d93257fcd83b432e1b0195b582ea45c63b3f57f parent 618990c

2 files changed

TODO.md+4โˆ’0
@@ -20,6 +20,10 @@ Remaining work, known bugs, and planned improvements.
2020
2121 - ๐Ÿ”ง **Duplicate max scroll offset calculation** โ€” `getMaxScrollOffset` in `cel.ts` and `computeMaxScrollOffset` in `paint.ts` implement the same logic. Should be extracted to a shared function.
2222
23+- ๐Ÿ”ง **Key events leak through layers** โ€” When no element is focused and the topmost layer's root has no `onKeyPress`, `handleKeyEvent` falls through to lower layers. Mouse input stops at the topmost layer with a node at the event position, but keyboard input doesn't follow the same rule. A modal overlay without its own root `onKeyPress` would leak keys to the base layer, breaking the "events target the topmost layer" principle.
24+
25+- ๐Ÿ”ง **`space-between` + `gap` double-spaces children** โ€” When both `justifyContent: "space-between"` and `gap` are set, children get `gap` spacing plus the distributed remaining space on top. The remaining-space calculation subtracts `totalGap` first, then `space-between` distributes what's left as extra gap โ€” so the effective gap is `gap + betweenGaps[i]`. CSS flex doesn't stack `space-between` on top of `gap` this way. The spec doesn't define this interaction.
26+
2327 ---
2428
2529 ## API Improvements
packages/core/src/paint.ts+1โˆ’9
@@ -201,8 +201,7 @@ function paintLayoutNode(
201201 const isVertical = node.type === "vstack";
202202 let scrollOffset = 0;
203203 if (isScrollable) {
204- const raw =
205- containerProps.scrollOffset ?? getContainerScroll(containerProps);
204+ const raw = containerProps.scrollOffset ?? 0;
206205 // Clamp to valid range so apps can pass large values to mean "scroll to end"
207206 const maxOffset = computeMaxScrollOffset(ln, isVertical);
208207 scrollOffset = Math.max(0, Math.min(raw, maxOffset));
@@ -600,13 +599,6 @@ function offsetToWrappedPos(
600599
601600 import type { ContainerProps } from "@cel-tui/types";
602601
603-const containerScrolls = new WeakMap<ContainerProps, number>();
604-
605-/** Get the scroll offset for an uncontrolled scrollable container. */
606-function getContainerScroll(props: ContainerProps): number {
607- return containerScrolls.get(props) ?? 0;
608-}
609-
610602 /**
611603 * TextInput state is keyed on the `onChange` function reference, which is
612604 * a stable identity across re-renders (the app provides the same closure).