Skip to content

fix(tabs): keep TTabsBar spanning the full width when scrollable - #1250

Open
lnuxe wants to merge 2 commits into
Tencent:developfrom
lnuxe:fix/ttabsbar-scrollable-width
Open

lnuxe wants to merge 2 commits into
Tencent:developfrom
lnuxe:fix/ttabsbar-scrollable-width

Conversation

@lnuxe

@lnuxe lnuxe commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

修复 #1246

💡 需求背景和解决方案

问题:TTabsBar 设置 isScrollable: true 后不再占满可用宽度——在横向无界父级(Column、Scaffold.body 等)中宽度收缩到内容宽,条形背景与底部分割线只覆盖首个标签附近区域,视觉上「不能自适应屏幕宽度」。

根因:isScrollable=true 时标签条走 MainAxisSize.min(_TabLabelBar),而 TTabsBar.build 的外层 Container 未声明宽度,在无界父级中被子内容收缩。

修复:外层 Container 补 width: double.infinity——条形背景/分割线恢复占满可用宽度;标签本身保持内容宽度并可滚动,超长标签串仍可左右滑动。

验证(widget 测试量化,390pt 屏):

场景 修复前 修复后
isScrollable: true,3 个标签 宽度 174(内容收缩) 390(占满)
isScrollable: true,12 个长标签 — 滑动后「选项12」可见(可滚动性保持)
isScrollable: false(默认) 390 390(无回归)

新增两条回归测试到 t_tab_bar_test.dart(全宽断言 + 长标签滚动断言),套件 14/14 通过,dart analyze 相关文件零告警。

📝 更新日志

  • fix(TTabsBar): 修复 isScrollable 时选项栏不再占满可用宽度、背景与分割线只覆盖首个标签的问题

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项。⚠️

  • 标题遵循 Conventional Commits 格式
  • 「相关 Issue」处带上修复的 Issue 链接
  • 无需 Spec(单行样式修复,无 API/契约变更)
  • 相关文档已补充或无须补充

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

完成

Web Demo

APK 下载

@lnuxe

lnuxe commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

CI 失败分诊(与同仓库同基线的 PR #1247 对照):

本 PR 引入(需处理)

  • Golden / Flutter 3.32.0 / Linux / group 1 of 2:4 个 t_tag_padding_golden_test 基线(272x48)恰好编码了本 PR 修复的收缩宽度——修复后正确渲染为 375x48。基线将按仓库惯例从 Linux CI 产物刷新后一并提交。

非本 PR 引入(基线固有,#1247 同样失败)

@lnuxe

lnuxe commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

基线已按仓库惯例从 Linux CI 产物刷新(b16eaf3)。当前 CI 状态:

✅ 本 PR 相关全部通过:

  • Golden / Flutter 3.32.0 / Linux / group 1 of 2(刷新前失败,现绿)
  • Golden / Flutter 3.32.0 / Linux / group 2 of 2
  • visual regression (flutter 3.32.0 linux)
  • Analyze / Flutter 3.32.0
  • Tests / components / examples / tooling 全部 3.32.0 与 latest 组件组
  • Build / ios、Build / web 双版本

❌ 剩余失败与基线一致(PR #1247 同样失败,非本 PR 引入):

  • Analyze / Flutter latest:278 issues,flutter latest 弃用 material/cupertino 包告警
  • Tests / tooling / Flutter latest:同源 snippet audit 弃用告警
  • Build / Android / Flutter latest:Gradle 8.14 < Flutter 9.3.1(上游构建配置问题)
  • test (flutter *):上述聚合任务

@lnuxe
lnuxe force-pushed the fix/ttabsbar-scrollable-width branch from b16eaf3 to 46c2402 Compare November 16, 2026 02:51
isScrollable=true switched the label strip to MainAxisSize.min, so the outer Container shrank to content width inside horizontally-unbounded parents: the bar background and divider only covered the first tab (issue Tencent#1246). Pin the outer container to double.infinity so the bar keeps occupying the available width while the labels themselves stay content-sized and scrollable.
…h bar

The previous baselines captured the shrunken 272px bar from the Tencent#1246 regression; regenerate them from the Linux CI golden-failures artifacts rendered with the fix in place (375px full-width bar).
@lnuxe
lnuxe force-pushed the fix/ttabsbar-scrollable-width branch from 46c2402 to 5a0d968 Compare November 17, 2026 02:03

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