feat(content-uploader): controlled expanded state#4629
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
ChangesControlled Expand/Collapse for Uploads Manager
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/elements/content-uploader/__tests__/ContentUploader.test.js`:
- Around line 700-714: The current test only covers the collapsed to expanded
transition (isExpanded: false → true). Add a complementary regression test case
in the same test file that covers the expanded to collapsed transition
(isExpanded: true → false) after completed uploads. Create a new test using the
same pattern as toggleUploadsManager in controlled mode, but initialize the
wrapper with isExpanded: true, call toggleUploadsManager, expect onToggle to be
called with false, verify that internal state remains true (controlled mode),
and assert that the minimize and cleanup side effects execute properly to
prevent stranding completed items in the controlled path.
In `@src/elements/content-uploader/ContentUploader.tsx`:
- Around line 1373-1380: The toggleExpand method in ContentUploader.tsx skips
side effects when the component is in controlled mode. When isExpandControlled()
returns true and the manager is being collapsed, the method only calls onToggle
but doesn't execute the necessary minimize side effects including onMinimize
callback, isAutoExpanded reset, and the post-collapse cleanup timer, which can
leave completed items stuck. Modify the controlled branch to check if isExpanded
is true (meaning we're collapsing), and if so, also invoke the same minimize
side effects that would normally run via minimizeUploadsManager(), ensuring
these cleanup operations happen regardless of whether the expand state is
controlled or uncontrolled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d8edf8f1-1c1c-47d7-8f96-8986dd5b4b88
📒 Files selected for processing (2)
src/elements/content-uploader/ContentUploader.tsxsrc/elements/content-uploader/__tests__/ContentUploader.test.js
olehrybak
left a comment
There was a problem hiding this comment.
Overall lgtm, left a small comment
4965d82 to
9eaeacd
Compare
Merge Queue Status
This pull request spent 9 minutes in the queue, with no time running CI. Waiting for
All conditions
ReasonThe merge conditions cannot be satisfied due to failing checks Failing checks: HintYou may have to fix your CI before adding the pull request to the queue again. |
Merge Queue Status
This pull request spent 11 minutes 27 seconds in the queue, including 11 minutes 3 seconds running CI. Required conditions to merge
|
* feat(content-uploader): controlled expanded state * feat(content-uploader): run onToggle uncontrolled * test(content-uploader): controlled-mode assertions * refactor(content-uploader): simplify branching --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This PR is a part of making an expanded state persistent. The persistent logic will be handled from the outside.
isExpandedandonTogglepropsisExpandedandonTogglepreservedSummary by CodeRabbit
New Features
Tests
onTogglecallback behavior, auto-expand threshold handling, and ensuring reset/minimize don’t mutate internal expanded state or fire callbacks in controlled mode.