fix(form-data): prevent input delays after navigating large forms - #4348
Conversation
Repeated render paths create new binding objects for the same data type and field. The identity-based default key retained every object and made each later edit reevaluate all prior bindings. Pass a stable path key through the Zustand context helpers and use it for form-data delayed selectors. In RA-0846-01, a 44-character input stayed below 0.4 seconds after three full form tours, while the prior build rose to 6.9 seconds.
Exercise direct and lax delayed selectors with fresh objects for the same binding. Repeated renders must reuse the cached selection, while a store change must still update the displayed value.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughDelayed-selector hooks now accept optional cache-key functions. Form-data selectors pass a key derived from each data-model reference. A regression test checks selector behavior with object arguments across re-renders and store updates. ChangesDelayed selector cache keys
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No actionable issue remains from this review; the change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The reviewed form selectors still read the same fields from their existing store. No security boundary change or security finding was established, although the available integration evidence does not cover every caller. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/publish |
PR release:
|
|
✅ Automatic backport successful! A backport PR has been automatically created for the The release branch The cherry-pick was clean with no conflicts. Please review the backport PR when it appears. |
) * fix(form-data): bound selector caches by data model path Repeated render paths create new binding objects for the same data type and field. The identity-based default key retained every object and made each later edit reevaluate all prior bindings. Pass a stable path key through the Zustand context helpers and use it for form-data delayed selectors. In RA-0846-01, a 44-character input stayed below 0.4 seconds after three full form tours, while the prior build rose to 6.9 seconds. * test(form-data): cover equivalent binding selector keys Exercise direct and lax delayed selectors with fresh objects for the same binding. Repeated renders must reuse the cached selection, while a store change must still update the displayed value. --------- Co-authored-by: Ole Martin Handeland <git@olemartin.org>
Description
Typing in a large form became slower after visiting more pages. Form-data selectors cached each newly created binding object by identity, even when it named a field already in the cache. Each edit then reevaluated all prior copies.
Cache form-data selections by data type and field. The Zustand context helpers now pass a custom cache key to delayed selectors. Repeated references to the same field share one cached selection, and store changes still update the value.
In RA-0846-01, typing 44 characters on “Kommentarar og merkader” after each full form tour took 2.46, 4.79, and 7.23 seconds before this change. It took 0.40, 0.30, and 0.39 seconds afterward. Retained heap after the three tours fell from 93 MiB to 52 MiB.
Related Issue(s)
Verification/QA
kind/*andbackport*label to this PR for proper release notes groupingSummary by CodeRabbit