Repository navigation
fix(icon): apply font-size on first render for non-image icons - #4711
Merged
Merged
Conversation
Apply iconStyle (including font-size) on the first setData for non-image icons so the initial frame uses the requested size. The image branch keeps its getRect-based width/height calculation unchanged.
Kk25380
requested review from
anlyyao,
betavs,
jarmywang,
jin0209,
novlan1 and
zydemail
as code owners
November 4, 2026 13:15
commit: |
Collaborator
TDesign Component Site Preview Open
|
The icon fix writes iconStyle on the first setData, so the close icon in calendar now renders with font-size: 48rpx on the first frame instead of an empty style. Update the :base snapshot accordingly. Relates to Tencent#4706.
betavs
approved these changes
Nov 4, 2026
anlyyao
reviewed
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #4706
🤔 这个 PR 的性质是?
🔗 相关 Issue
#4706:指定 size 后 t-icon 首次渲染使用继承字号,随后跳到目标字号;重新挂载可稳定复现。
💡 需求背景和解决方案
问题:指定
size的字体图标首次渲染先以继承字号显示,下一次setData才跳到目标字号,视觉上存在一帧尺寸跳变。根因:
Icon.setIconStyle()中iconStyle(含font-size)在调用前已同步算好,却被放进第一次setData({ isImage })的回调里,直到第二次setData才写入。getRect异步测量只有图片图标分支才需要,普通字体图标被这次异步连带延迟一帧。改动:非图片图标在首次
setData时同步写入iconStyle并return;图片图标保留原有异步分支与宽高计算。不新增属性、不改变跨端 API,仅影响首帧表现。📝 更新日志
tdesign-miniprogram
size后首次渲染字号跳变@tdesign/uniapp
@tdesign/uniapp-chat
☑️ 请求合并前的自查清单