Skip to content

feat(content-uploader): controlled expanded state#4629

Merged
mergify[bot] merged 6 commits into
masterfrom
uploads-manager-controlled-expand
Jun 16, 2026
Merged

feat(content-uploader): controlled expanded state#4629
mergify[bot] merged 6 commits into
masterfrom
uploads-manager-controlled-expand

Conversation

@dealwith

@dealwith dealwith commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

This PR is a part of making an expanded state persistent. The persistent logic will be handled from the outside.

  1. Added isExpanded and onToggle props
  2. Logic without isExpanded and onToggle preserved
  3. Tests added

Summary by CodeRabbit

  • New Features

    • The uploads manager now supports parent-controlled expand/collapse via new optional props to set the expanded state and receive toggle events.
    • Auto-expand and minimize/reset behaviors now consistently respect controlled mode, keeping internal expansion from changing unexpectedly.
  • Tests

    • Added Jest coverage for controlled vs. uncontrolled modes, including onToggle callback behavior, auto-expand threshold handling, and ensuring reset/minimize don’t mutate internal expanded state or fire callbacks in controlled mode.

@dealwith
dealwith marked this pull request as ready for review June 15, 2026 15:39
@dealwith
dealwith requested review from a team as code owners June 15, 2026 15:39
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

ContentUploader adds two optional props, isExpanded and onToggle, to support a controlled expand/collapse mode for the uploads manager. Two new helpers (isExpandControlled, getIsExpanded) resolve the effective expansion state, and all internal methods (expandUploadsManager, toggleUploadsManager, resetUploadManagerExpandState, addToQueue) are updated to skip internal state mutations when controlled. Render and queue-reset logic also switch to the resolved helper value.

Changes

Controlled Expand/Collapse for Uploads Manager

Layer / File(s) Summary
Props and expand-state resolution helpers
src/elements/content-uploader/ContentUploader.tsx
Adds isExpanded?: boolean and onToggle?: (isExpanded: boolean) => void to ContentUploaderProps. Introduces isExpandControlled() and getIsExpanded() to pick between the controlled prop and state.isUploadsManagerExpanded. Updates resetUploadManagerExpandState to skip internal state mutation when controlled.
Internal method guards for controlled mode
src/elements/content-uploader/ContentUploader.tsx
addToQueue reads expanded state through getIsExpanded(). expandUploadsManager returns early in controlled mode. toggleUploadsManager delegates to onToggle(!isExpanded) and skips setState when controlled. resetUploadsManagerItemsWhenUploadsComplete uses getIsExpanded() instead of destructuring state directly.
Render wiring and controlled/uncontrolled tests
src/elements/content-uploader/ContentUploader.tsx, src/elements/content-uploader/__tests__/ContentUploader.test.js
render derives isUploadsManagerExpanded from getIsExpanded() before passing it to UploadsManager. New Jest suite covers: controlled prop-driven isExpanded forwarding to UploadsManagerBP, toggleUploadsManager calling onToggle without mutating state (controlled) vs. flipping state without calling onToggle (uncontrolled), auto-expand threshold no-ops, and resetUploadManagerExpandState no-ops in controlled mode.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • box/box-ui-elements#4573: Directly sets isExpanded on UploadsManagerBP from state.isUploadsManagerExpanded in the modernized path — the same prop integration point this PR upgrades to support controlled mode.

Suggested labels

ready-to-merge

Suggested reviewers

  • reneshen0328
  • jpan-box
  • olehrybak

Poem

🐇 A toggle was once just a boolean flip,
Now the consumer can steer the ship!
isExpanded in hand, onToggle to call,
Controlled or uncontrolled — it handles them all.
The uploads manager bows to your will,
And the bunny hops on with a thrill! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding controlled expanded state support to the content-uploader component.
Description check ✅ Passed The PR description clearly outlines the changes (new props, backward compatibility, tests) and the overall objective (making expanded state persistent), providing sufficient context for reviewers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch uploads-manager-controlled-expand

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f63ba1 and 4ba303a.

📒 Files selected for processing (2)
  • src/elements/content-uploader/ContentUploader.tsx
  • src/elements/content-uploader/__tests__/ContentUploader.test.js

Comment thread src/elements/content-uploader/__tests__/ContentUploader.test.js
Comment thread src/elements/content-uploader/ContentUploader.tsx Outdated
olehrybak
olehrybak previously approved these changes Jun 15, 2026

@olehrybak olehrybak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall lgtm, left a small comment

Comment thread src/elements/content-uploader/ContentUploader.tsx Outdated
Comment thread src/elements/content-uploader/ContentUploader.tsx Outdated
olehrybak
olehrybak previously approved these changes Jun 16, 2026
@dealwith
dealwith force-pushed the uploads-manager-controlled-expand branch from 4965d82 to 9eaeacd Compare June 16, 2026 14:15
@dealwith dealwith self-assigned this Jun 16, 2026
@dealwith
dealwith requested a review from jfox-box June 16, 2026 14:44
@mergify

mergify Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-06-16 14:52 UTC · Rule: Automatic strict merge
  • Checks failed · in-place
  • 🚫 Left the queue2026-06-16 15:01 UTC · at 49128de5bbdf7244da681e6dc6ca9339b8d22584

This pull request spent 9 minutes in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = lint_test_build
    • check-skipped = lint_test_build
    • check-success = lint_test_build
  • any of: [🛡 GitHub branch protection]
    • check-neutral = license/cla
    • check-skipped = license/cla
    • check-success = license/cla
  • any of: [🛡 GitHub branch protection]
    • check-neutral = lint_pull_request
    • check-skipped = lint_pull_request
    • check-success = lint_pull_request
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = lint_test_build
    • check-skipped = lint_test_build
    • check-success = lint_test_build
  • any of [🛡 GitHub branch protection]:
    • check-neutral = license/cla
    • check-skipped = license/cla
    • check-success = license/cla
  • any of [🛡 GitHub branch protection]:
    • check-neutral = lint_pull_request
    • check-skipped = lint_pull_request
    • check-success = lint_pull_request
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Summary
    • check-neutral = Summary
    • check-skipped = Summary

Reason

The merge conditions cannot be satisfied due to failing checks

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

@mergify

mergify Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-06-16 15:53 UTC · Rule: Automatic strict merge
  • Checks passed · in-place
  • Merged2026-06-16 16:04 UTC · at bee211c17a12390dde7decc5092c0d9887356bf8 · squash

This pull request spent 11 minutes 27 seconds in the queue, including 11 minutes 3 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Summary
    • check-neutral = Summary
    • check-skipped = Summary
  • any of [🛡 GitHub branch protection]:
    • check-success = lint_test_build
    • check-neutral = lint_test_build
    • check-skipped = lint_test_build
  • any of [🛡 GitHub branch protection]:
    • check-success = license/cla
    • check-neutral = license/cla
    • check-skipped = license/cla
  • any of [🛡 GitHub branch protection]:
    • check-success = lint_pull_request
    • check-neutral = lint_pull_request
    • check-skipped = lint_pull_request

@mergify mergify Bot removed the dequeued label Jun 16, 2026
@mergify
mergify Bot merged commit c3d21b1 into master Jun 16, 2026
13 checks passed
@mergify
mergify Bot deleted the uploads-manager-controlled-expand branch June 16, 2026 16:04
@mergify mergify Bot removed the queued label Jun 16, 2026
kduncanhsu pushed a commit to kduncanhsu/box-ui-elements that referenced this pull request Jun 18, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants