Skip to content

fix: support CSP nonce in getTargetScrollBarSize - #821

Open
HhBeingStrong wants to merge 1 commit into
react-component:masterfrom
HhBeingStrong:fix/scrollbar-csp-nonce
Open

HhBeingStrong wants to merge 1 commit into
react-component:masterfrom
HhBeingStrong:fix/scrollbar-csp-nonce

Conversation

@HhBeingStrong

@HhBeingStrong HhBeingStrong commented Oct 15, 2026 •

Copy link
Copy Markdown

Add an optional CSP configuration to getTargetScrollBarSize and forward
its nonce to the temporary styles used for scrollbar measurement.

Existing calls remain compatible. Callers need to pass their CSP configuration.

Related to #613

Validation: all 32 test suites passed; TypeScript check passed.

Summary by CodeRabbit

  • 新功能
    • 滚动条尺寸测量现在支持传入 CSP 配置,以便在启用样式 nonce 的环境中正常使用。
    • 使用 Ant Design ConfigProvider 的组件可将其 csp 配置传入;该工具不会自动读取 React context。
  • 文档
    • 补充了 CSP nonce 的配置说明及使用方式。

@vercel

vercel Bot commented Oct 15, 2026

Copy link
Copy Markdown

@HhBeingStrong is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55cf8bad-374c-472a-bef6-6e08619ac470
📥 Commits

Reviewing files that changed from the base of the PR and between e12854b and 3d7106f.

📒 Files selected for processing: 3
  • docs/demo/getScrollBarSize.md
  • src/getScrollBarSize.tsx
  • tests/getScrollBarSize.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

getTargetScrollBarSize 现在接受可选的 CSP 配置,并将其传递给测量用样式更新流程。新增测试覆盖配置传递和节点清理。文档说明如何传入 nonce,以及组件如何转发 ConfigProvider 的 csp 配置。

Changes

滚动条测量的 CSP nonce 支持

层 / 文件 摘要
CSP 参数传递与验证
src/getScrollBarSize.tsx, tests/getScrollBarSize.test.ts, docs/demo/getScrollBarSize.md
新增带可选 nonce 的 CSPConfig。getTargetScrollBarSize 将可选配置传递给测量流程和 updateCSS。测试验证不同配置下的结果、样式 nonce 和节点清理。文档说明如何传入 nonce,并明确工具不会自动读取 React context。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 3d710

No actionable merge-blocking issue is identified; the change appears ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确概括了主要变更:为 getTargetScrollBarSize 支持 CSP nonce。标题简洁、明确,并与代码、测试和文档变更一致。
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

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

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

小兔带来一枚 nonce,
临时样式轻轻落下。
滚动条量出宽与高,
测量完毕,节点回家。
文档记下传参方法,
月光下小兔蹦跶。

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

This branch has not been deployed

No deployments
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.

1 participant