Repository navigation
feat(Popup): 小程序与 UniApp 新增可选 maxWidth 属性 - #4742
Open
Huuyii-sleeping wants to merge 2 commits into
Open
Huuyii-sleeping wants to merge 2 commits into
Huuyii-sleeping wants to merge 2 commits into
Conversation
Huuyii-sleeping
requested review from
anlyyao,
betavs,
jarmywang,
jin0209,
novlan1 and
zydemail
as code owners
November 23, 2026 13:53
This was referenced Nov 23, 2026
8 tasks done
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.
🤔 这个 PR 的性质是?
🔗 相关 Issue
关联 Tencent/tdesign-common#2743。
配套 PR:common #2791、Mobile Vue #2414、Mobile React #1020、小程序/UniApp #4742。API 源定义 #1074 已由维护者合入。
💡 需求背景和解决方案
宽屏下顶部、底部 Popup 可以通过可选
maxWidth限制宽度。数字单位为 px,字符串支持 CSS 长度和none。未传参数时不设置最大宽度,默认仍为全宽;其他方向忽略该参数。按维护者建议,顶部和底部基础类直接设置
right: 0; margin: 0 auto,配合已有left: 0实现水平居中。组件只计算内联 max-width,不新增标记 class。基础类统一居中也意味着:未传 maxWidth 但设置了较窄自定义 width 的顶部/底部弹层会居中,不再靠左;自定义宽度值保持不变。同一 PR 为小程序和 UniApp 补齐 maxWidth 类型、props、API 文档和内联样式处理。两端直接在现有 top/bottom 类中居中,不新增 class;保留导航栏偏移、动画、安全区、自定义样式、zIndex 和事件契约。字符串还支持平台可用的 rpx 单位。
按“其他技术栈同理”的审查要求,删除单独的 max-width 测试文件,把小程序 maxWidth 集成用例及 UniApp 样式计算用例统一并入已有
packages/components/popup/__test__/index.test.js;UniApp Popup 此前没有现有测试文件。无需新增示例。视觉行为参考 common/Vue 配套 PR 的截图。该截图来自 Chrome,未作为小程序/UniApp 真机结果。两端样式在本仓库实现,无需等待 common 样式同步。
✅ 验证
node node_modules/gulp/bin/gulp.js --gulpfile script/gulpfile.dist.js --cwd ./完整小程序分发构建通过,无 TypeScript 错误。git diff --check通过。UniApp 现有 emits/_style 规则警告仍存在。📝 更新日志
tdesign-miniprogram
@tdesign/uniapp
@tdesign/uniapp-chat
无独立修改。
☑️ 请求合并前的自查清单