Skip to content

fix: type resize callback sizes - #628

Merged
yoyo837 merged 4 commits into
react-component:masterfrom
nrps9909:codex/resize-callback-types
Aug 28, 2026
Merged

fix: type resize callback sizes#628
yoyo837 merged 4 commits into
react-component:masterfrom
nrps9909:codex/resize-callback-types

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose the runtime size argument on onResizeStart
  • expose the runtime size argument on onResizeEnd
  • verify both callback values in the resizable Drawer integration test

Problem

useDrag already invokes all three resize callbacks with a numeric size, and its internal option types reflect that behavior. The public DrawerProps and DrawerPopupProps types only declared onResizeStart and onResizeEnd as () => void. A consumer that typed either callback parameter as number therefore received TS2322 even though that number is supplied at runtime.

The regression change fails on current master with two TS2322 errors and passes after aligning the public callback signatures with useDrag.

Validation

  • rc-test --runInBand (5 suites, 51 tests)
  • tsc --noEmit
  • ESLint on src (no errors; 3 existing hook warnings)
  • father build (ESM, CJS, declarations)
  • Less compilation
  • Prettier and git diff --check

I checked the current issues and open PR changed files. #591 only changes the CSSMotion ref placement, while #472 concerns mask scroll locking; no open work changes these callback signatures.

Summary by CodeRabbit

  • 功能改进

    • 调整大小的抽屉会在开始和结束时向回调传递当前尺寸(像素)。
    • 示例现可显示当前尺寸及调整状态,其他调整大小行为保持不变。
  • 文档

    • 更新 API 文档和示例说明,明确调整大小回调的尺寸参数。
  • 测试

    • 增加对回调接收实际抽屉尺寸的验证。

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 03cd0c59-1c21-4f46-84c9-15343f6d85bb

📥 Commits

Reviewing files that changed from the base of the PR and between 77c44f5 and d634662.

📒 Files selected for processing (1)
  • README.md

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

Drawer 的尺寸回调现在接收当前尺寸参数。实现透传该参数。测试、API 文档和示例同步更新。

Changes

可调整大小回调

Layer / File(s) Summary
回调契约与尺寸透传
src/Drawer.tsx, src/DrawerPopup.tsx, tests/index.spec.tsx
onResizeStartonResizeEnd 的签名改为接收 size: numberDrawerPopup 透传尺寸参数。测试验证两个回调均收到 200
文档与示例更新
README.md, docs/demo/resizable.md, docs/examples/resizable.tsx
API 文档、演示说明和示例同步更新。示例显示当前尺寸,并记录调整开始和结束状态。

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to d6346

The resize callbacks now expose the numeric size they already receive at runtime, with focused test coverage and validation passing; no actionable merge-blocking risk remains.

Suggested reviewers: afc163

Poem

小兔拉动抽屉边,
尺寸数字跳眼前。
开始回调报两百,
结束回调也相连。
文档示例同步更新。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题明确说明了调整 resize 回调参数类型,准确对应本次公开类型和回调尺寸参数的变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4…
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.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5bb1cc6) to head (d634662).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #628   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          209       209           
  Branches        75        75           
=========================================
  Hits           209       209           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yoyo837

yoyo837 commented Aug 28, 2026

Copy link
Copy Markdown
Member

Please continue to refine the examples and docs.

@nrps9909

Copy link
Copy Markdown
Contributor Author

Updated in 77c44f5. The README now documents the size argument for all three resize callbacks, the resizable demo page explains the pixel-size contract, and the interactive example displays the current size plus the start/end callback values instead of only logging callback names. I revalidated TypeScript, all 5 suites / 51 tests, full source/docs/tests lint (0 errors; existing warnings only), the production dumi build, Prettier, and diff checks.

@yoyo837

yoyo837 commented Aug 28, 2026

Copy link
Copy Markdown
Member

This PR contains a lot of unnecessary diff due to Markdown formatting. I'd like to revert/roll back these formatting changes.

@nrps9909

Copy link
Copy Markdown
Contributor Author

Rolled back the README table formatting in 9975b0b. The PR is now limited to the callback type/runtime changes, focused regression test, and the requested resizable demo explanation/example; README.md is byte-for-byte unchanged from master.

@yoyo837

yoyo837 commented Aug 28, 2026

Copy link
Copy Markdown
Member

The documentation does need to be updated for this API change, but please avoid reformatting the Markdown files. Formatting changes create a large amount of unrelated diff and make the PR harder to review. Please keep the documentation changes focused on the necessary content only.

@nrps9909

Copy link
Copy Markdown
Contributor Author

Updated in d634662c. The README now changes only the existing resizable API row to add the (size: number) parameter to onResizeStart and onResizeEnd; no other README line or Markdown formatting changed. The focused demo text/example remains in place, so the public API contract and its usage are both documented.

@yoyo837
yoyo837 merged commit 1a18469 into react-component:master Aug 28, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants