Skip to content

fix(runner): recalc fontSize 0.5s after window resize, fix #18653#19218

Open
ilharp wants to merge 1 commit into
NervJS:mainfrom
ilharp-contrib:fix-runner-fontsize
Open

fix(runner): recalc fontSize 0.5s after window resize, fix #18653#19218
ilharp wants to merge 1 commit into
NervJS:mainfrom
ilharp-contrib:fix-runner-fontsize

Conversation

@ilharp

@ilharp ilharp commented May 14, 2026

Copy link
Copy Markdown

这个 PR 做了什么? (简要描述所做更改)

部分移动端浏览器(如微信 WebView)加载或刷新时有概率将 window resize 为一个 height 很小的大小,之后又恢复。经过测试在 window resize event 0.5s 之后再次尝试计算 fontSize 可解决。

影响范围:v3.7.0-alpha.27 以来的所有版本

详情看 #18653 中评论

这个 PR 是什么类型? (至少选择一个)

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

Summary by CodeRabbit

发版说明

  • 改进
    • 优化了响应式设计中字体大小的动态调整机制。当窗口大小改变时,系统现在会立即重新计算根节点的字体大小,并在短延迟后再进行一次调整,使界面布局能更快更稳定地适应屏幕尺寸的变化。

Review Change Stack

…8653

部分移动端浏览器(如微信 WebView)加载或刷新时有概率将 window resize 为一个 height 很小的大小,之后又恢复。经过测试在 window resize event 0.5s 之后再次尝试计算 fontSize 可解决。

影响范围:v3.7.0-alpha.27 以来的所有版本

详情看 NervJS#18653 中评论
@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 76c89b11-9a67-48b8-99b4-b181096ea67d

📥 Commits

Reviewing files that changed from the base of the PR and between 9c6c511 and 04b38af.

📒 Files selected for processing (2)
  • packages/taro-vite-runner/src/utils/html.ts
  • packages/taro-webpack5-runner/src/webpack/H5WebpackPlugin.ts

Walkthrough

Two build runner HTML generators are updated: Vite and Webpack5 now both add a 500ms delayed re-execution of the document root font-size calculation in their window resize event handlers, changing the callback from immediate-only execution to immediate plus delayed execution.

Changes

Responsive font-size recalculation

Layer / File(s) Summary
Delayed font-size recalculation in resize handlers
packages/taro-vite-runner/src/utils/html.ts, packages/taro-webpack5-runner/src/webpack/H5WebpackPlugin.ts
The inline pxtransform scripts generated by both Vite and Webpack5 runners now execute the font-size recalculation function f() immediately and again after 500ms on window resize, instead of only immediate execution, to properly handle viewport reflows caused by URL query parameter changes in browser-mode H5 applications.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit hops through viewport changes,
Font-size flows with gentle ranges.
Now resize takes two-phase stride,
Five hundred mills let styles align with pride! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题清晰指出了主要修复内容:在window resize后0.5秒重新计算fontSize,并关联了相应的issue #18653
Linked Issues check ✅ Passed 代码变更直接解决了issue #18653中的问题:通过在window resize回调中添加500ms延迟重算fontSize,解决移动端WebView异常resize导致的字体大小计算错误。
Out of Scope Changes check ✅ Passed 所有变更仅涉及pxtransform运行时脚本中的resize回调逻辑,范围限定在解决issue #18653的问题域内,无超出范围的改动。

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

This was referenced May 16, 2026
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.

Taro4.1.8下,h5设置browser模式,改变url的query参数后刷新h5页面,字体大小一直20px

1 participant