Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(tabs): create tabs panel not update tab bar when async generate it (#1254) #1258

Merged
merged 4 commits into from
Aug 15, 2022

Conversation

NWYLZW
Copy link
Collaborator

@NWYLZW NWYLZW commented Aug 10, 2022

🤔 这个 PR 的性质是?

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

🔗 相关 Issue

#1254

💡 需求背景和解决方案

具体问题

使用异步 api 去创建 tab panel 的时候会导致 tab nav 的 active index 没办法计算出来

解决方法

  • 不使用 itemList 对数据作为 getIndex 函数的 deps,使用实际需要的 value 数组

其次需要考虑一种边界情况,所以对默认逻辑进行了优化
当用户传入了 value 但是没有传入 tab panel 列表的时候不需要默认选择第一个元素的
这个时候 getIndex 函数的返回值应该是 -1

目的是为了能够让后面用户传入 tab panel 的时

tab bar 能够检测到 active id 属性的更新 如果是之前的逻辑,active id 默认为 0,用户后面传入 tab panel 的时候,默认也是第一个元素会导致不更新

📝 更新日志

  • fix(tabs): create tabs panel not update tab bar when async generate it

  • 本条 PR 不需要纳入 Changelog

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

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

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@github-actions
Copy link
Contributor

github-actions bot commented Aug 10, 2022

完成

@codecov-commenter
Copy link

codecov-commenter commented Aug 10, 2022

Codecov Report

Merging #1258 (a8ba3f4) into develop (b249875) will increase coverage by 0.09%.
The diff coverage is 33.33%.

@@             Coverage Diff             @@
##           develop    #1258      +/-   ##
===========================================
+ Coverage    59.73%   59.83%   +0.09%     
===========================================
  Files         1007     1007              
  Lines        17661    17662       +1     
  Branches      4032     4033       +1     
===========================================
+ Hits         10550    10568      +18     
+ Misses        7111     7094      -17     
Impacted Files Coverage Δ
src/cascader/Cascader.tsx 57.89% <0.00%> (ø)
src/tabs/TabBar.tsx 100.00% <100.00%> (+60.71%) ⬆️
src/tabs/TabNav.tsx 85.10% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/tabs/TabNav.tsx Outdated Show resolved Hide resolved
src/tabs/TabNav.tsx Outdated Show resolved Hide resolved
src/tabs/TabNav.tsx Outdated Show resolved Hide resolved
src/tabs/TabNav.tsx Show resolved Hide resolved
@honkinglin
Copy link
Collaborator

更新下snapshot

@NWYLZW
Copy link
Collaborator Author

NWYLZW commented Aug 12, 2022

更新下snapshot

我的问题应该不是因为 snapshot,我没有改动 example
我看了一下挂掉的原因
tab bar 的 style 在 describe 和 test 俩个级别下的测试结果不一样
我上一个 commit 都没有这个问题来着
可能是修改的内容导致的

@honkinglin honkinglin merged commit 8cd901a into Tencent:develop Aug 15, 2022
@github-actions github-actions bot mentioned this pull request Aug 15, 2022
16 tasks
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.

4 participants