Repository navigation
fix(useResizable): add structured percentage sizing - #5783
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsLayout (@astryxdesign/core) · View in Storybook
Resizable (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual RegressionStatus: No visual change across 14 compared shot(s). Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
left a comment
There was a problem hiding this comment.
This changes released sizing and leaves several builders with geometry AST-010 does not permit.
- Without a ref,
50%paints 250px in a 1000px viewport. With the returned ref, the default tracks 374→254 on container shrink, and a 382px clamp revives to 562px on growth. AST-010 FR1/FR4/FR6 require one-time pixel selection and persistent clamping. (useResizable.ts:367) - Vertical and bordered containers measure border-box width. Chromium saw a 934px content box but
aria-valuemax=562, not 560. AST-010 FR2/API1/API2 require a configured ref and content-box active axis. (useResizable.ts:330) - Unified bounds lose to deprecated aliases, duplicate pairs type-check,
resize(NaN)becomesNaN, and callback-less cleanup can remove peer observers. AST-010 FR11/FR12/API4/API6 require unified precedence, exact validation, and independent cleanup. (useResizable.ts:353;sharedResizeObserver.ts:102)
Please add no-ref, axis/content-box, re-clamp, invalid/alias, multi-region, SSR/hydration, and cleanup coverage.
[Reviewed by Robohands]
28da9a1 to
77d483c
Compare
|
(Replaces my previous comment, which was too long.) Reworked onto AST-010. All three findings reproduced and fixed, measured rather than argued. 1 · No-ref default, one-time selection, reviving clamps (FR1/FR4/FR6) — all three real.
2 · Border-box and axis (FR2/API1/API2) — confirmed exactly as you measured: a 934px content box reporting 3 · Precedence, validation, cleanup (FR11/FR12/API4/API6)
Coverage: no-ref, axis/content-box, re-clamp, invalid/alias, multi-region, SSR/hydration, cleanup. 79 Resizable tests; 17 of the new ones fail against Peer-safe cleanup is split out as #5817, because §Implementation-requirements 9 asks for it to stay independently reviewable; this PR stacks on it, and FR11 needs it since multi-region puts every region on one container. |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — no-ref sizing, ordinary content-box measurement, validation, alias precedence, and peer-safe observer cleanup now reconcile.
Builders using percentage bounds can still get panels that revive or retain stale geometry. A default clamps 454→240 as its container shrinks, then revives to 454 on growth; in vertical writing modes one config uses a 160 default with 90/360 bounds. Cancellation exposes the same split: pointerup releases a frozen basis and clamps 600→300, but pointercancel leaves 600, and iframe crossing leaves the drag active. Replacing containerRef.current can set max to 0 because observation remains on the old element.
Please contract this to one authoritative pixel selection, one basis tied to the current element/axis, and one terminal gesture path. _direction also became required on exported ResizableProps; a valid pre-PR object no longer compiles. Could that public type stay source-compatible?
[Reviewed by Robohands]
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the earlier no-ref, content-box, validation, and alias issues now reconcile, but builders can still lose panel geometry in three current-head paths.
- Replacing the element behind the same
containerRefleaves the detached element observed. Chromium went from max 199 in a 400px box to size/max 0 in its 800px replacement, not 399; a hidden mount also overwrote a saved 321px width with 0. (useResizable.ts:464,:697) pointercancelcleans listeners without_onResizeEnd(), so the frozen basis never releases. After shrinking 998→598px during a cancelled drag, size/ARIA max stayed 499 instead of 299. (ResizeHandle.tsx:428)ResizablePropsis exported; requiring_directionmakes every previously valid object literal fail to compile. Please keep the mismatch diagnostic source-compatible. (useResizable.ts:163)
Please rebase too: current main rewrites the same pointer lifecycle.
[Reviewed by Robohands]
|
Rebased as a merge of All three reproduced in Chromium 149 first, then fixed:
Negative control per fix: reverted on its own, its focused tests fail and the Chromium numbers go back to 600 / 0 / 499. Gates: 9003 core + lab tests (316 files); core build, One correction to my own earlier claim: I wrote that Stack: #5817 is this branch's first commit, not duplicated work — land it first and this diff shrinks to the |
dd8e7a4 to
6ab133c
Compare
|
Restacked onto corrected #5817 head All three current-head findings reconcile:
Chromium also found one path the earlier tests missed: a raw 321px default initially clamped to 200px revived to 321px when its container grew. The initialized clamp is now committed as ordinary pixel state, so it cannot revive. The new default-revival test fails on the prior PR head ( Validation: 288 files / 8674 core tests, |
|
Fixed the exact-head migration-warning bug. The shared alias-warning latch is now two independent latches, so untyped input supplying both old/new pairs emits both required warnings: one naming ignored Added one combined-conflict regression that asserts both unified values win and both full warning messages fire exactly once. Negative control against the prior head fails exactly as reported: expected 2 warnings, got 1. Validation: Resizable + observer 111 tests, full core 290 files / 8740 tests, TypeScript, lint, |
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the prior alias-warning ask now reconciles: both warnings fire, and the focused Resizable tests pass. Two current-head paths still need tightening.
- A numeric-only region with
containerRefdoubles hook work: 1→2, 10→20, and 50→100 calls. The ref-following effect records the element even though no percentage can consume it, contradicting the one-pass release note. Gate that work on percentage use and add this combination to the regression test. - Six shipped vertical examples/templates omit the hook’s new
direction, so they now emit the mismatch warning. Please make those pairings satisfy the new contract.
[Reviewed by Robohands]
Add Table-aligned pixel() and percent() descriptors with one pixel floor or ceiling while keeping state, persistence, callbacks, paint, and ARIA in resolved pixels.
cixzhang
left a comment
There was a problem hiding this comment.
Thanks — the structured percent() API matches AST-010, but the two prior asks remain open.
- A numeric-only region with
containerRefstill doubles hook work: 1→2, 10→20, and 50→100 calls. The ref-following effect records DOM identity even when no percentage can consume it. Please gate that work on percentage use and add this combination to the one-pass regression. (useResizable.ts:624) - Six vertical examples/templates still pair the hook’s default horizontal direction with a vertical handle. Chromium emits the mismatch warning in all three affected hook stories; the other three have the same pairing. Please pass
direction: 'vertical'to every vertical hook. (useResizable.stories.tsx:231;Resizable.stories.tsx:97;ide/page.tsx:219)
[Reviewed by Robohands]
|
@cixzhang I rechecked both asks against exact head
No code was changed for this verification. The normal final-head review-request workflow already succeeded and GitHub currently lists you as requested: https://github.com/facebook/astryx/actions/runs/33728610697 |
|
Fixed the two review blockers at
|
cixzhang
left a comment
There was a problem hiding this comment.
Thanks, the prior performance and direction asks now reconcile. Structured sizing matches AST-010; numeric-only mounts stay single-pass, and all six vertical pairings are aligned and guarded.
[Reviewed by Robohands]
…#6041) The table-inbox reading pane (#5934) computes maxSizePx itself from a plain ResizeObserver measurement (Math.max(paneFloor, surfaceWidth - listFloor)) rather than a containerRef percentage bound. A same-head review on #5934 found that after widening the pane past a later surface-derived maximum, the pane stayed oversized and overlapped the list instead of clamping down to the new ceiling. Investigation shows this exact literal-maxSizePx-shrink path is already covered by useResizable's general FR4 bounds-reclamp (landed in #5783, commit 311deef): re-resolving resolvedMax from a changed caller-supplied maxSizePx every render already re-clamps the committed selection, independent of whether the bound is a percentage or a plain number. Both a hook-level and a page.tsx-composition-level reproduction of the #5934 review's exact sequence (drag to 1066px, then narrow the derived max to 834px) already pass on current main. Add the regression directly to useResizable's FR4/FR6 suite so this caller-recomputed-pixel path can't silently regress again: one test pins the clamp itself and the ARIA-visible _maxSizePx/_size, the other pins that an in-range user choice is left untouched (AST-010 FR4: bounds clamp, they never scale). No runtime change: the fix is already on main.
useResizablenow resolves percentage configuration against an explicit basis and keeps state, persistence, paint, callbacks, and ARIA in pixels.Structured sizing
pixel()andPixelWidthare the existing Table binding and type; Resizable does not define another fixed-size helper.percent()is Resizable-owned because it is a literal percentage of one basis, unlike Table's sibling-weightproportional().minormax. Exact'40%'remains the only unbounded percentage spelling.Npx, exactN%, and the releasedminSizePx/maxSizePxaliases remain compatible.min()/max()parsing is deliberately unsupported.Semantics
containerRefselects the content-box basis on the active axis. Without it, the released viewport basis and 1200px SSR fallback remain.defaultSizeresolves once to pixels. A structured default applies its floor or ceiling once and then releases its observer.minSize/maxSizeremain live and re-clamp the selected pixel state when their basis changes.The original defect was a CSS-only percentage ceiling: paint stopped at the CSS cap while state and
aria-valuenowcontinued past it. The bound now clamps the pixel state itself, so panel width, storage, callbacks, and ARIA agree.Browser evidence
Chromium 149 against the built Storybook verified:
percent(40, {min: pixel(333)})resolves to 399px on a 998px basis and 333px on a 498px basis;aria-valuenowmatch throughout;Verification
SideNav's simplified pixel-only width configuration is unchanged.