Repository navigation
fix(ui): keep Sheet close handlers current before passive effects flush - #3629
Conversation
The Close button, swipe and back handlers read onCloseRef/requestCloseRef, which were updated in a passive useEffect. A click landing after a commit but before the passive flush called the previous render's onClose. AdminRenewedSheet hit this in CI (admin-renewed-sheet.dom.test.tsx 'clears the form once a save has actually completed'): Close ran the pre-save handleClose and skipped the reset. Update the refs in a layout effect; add a deterministic regression test that fails without the fix.
There was a problem hiding this comment.
BigSimmo has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Claude encountered an error after 2s —— View job I'll analyze this and get back to you. |
PR Summary by QodoKeep Sheet close handlers current before passive effects flush
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
🏁 CodeAnt Quality Gate ResultsCommit: ✅ Overall Status: PASSEDQuality Gate Details
|
Code Review by Qodo
No findings for this group No findings for this group No findings for this group Resolved findings 1.
|
Code Review ✅ Approved🟡 Medium risk · Moving Sheet close-handler refs to a layout effect changes close timing; stale callbacks could otherwise skip resetting saved state after a save. Moves VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Approved For more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Important Your trial ends in 4 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more. Was this helpful? React with 👍 / 👎 | Gitar |
CodeAnt PR Risk: Low Risk
Assessed commit: |
User description
Summary
SheetupdatedonCloseRef/requestCloseRefin a passiveuseEffect. A Close/swipe/back that landed after a commit but before the passive flush called the previous render'sonClose(stale closure).tests/admin-renewed-sheet.dom.test.tsx› "clears the form once a save has actually completed", line 138): Close ranAdminRenewedSheet's pre-savehandleClose, so the saved state was not reset.useLayoutEffect. Regression test intests/sheet.dom.test.tsxclicks Close from a MutationObserver right after the commit.Areas touched: Design system
Verification
expected [ +0 ] to deeply equal [ 1 ]) and passes with it;vitest run tests/sheet*.test.tsx tests/admin-*.dom.test.tsx→Test Files 28 passed (28), Tests 352 passed (352); eslint clean; push guard typecheck passed.Risk and rollout
Notes
Summary by cubic
Fixes a stale-closure bug where
Sheet's Close button, swipe, and back handlers could call the previous render'sonClosewhen a click landed right after a commit but before passive effects flushed.Now updates the close handler refs in an isomorphic layout effect (
useLayoutEffecton the client,useEffecton the server), and adds a regression test that reproduces the race by clicking Close from a MutationObserver immediately after a commit.Written for commit a6906d3. Summary will update on new commits.
CodeAnt-AI Description
Keep sheet close actions in sync with the latest state
What Changed
Impact
✅ Saved sheet state resets on close✅ Close actions honor the latest state💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit