-
Notifications
You must be signed in to change notification settings - Fork 260
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.taro.tsx): 解决在不需要滚动的时候,切换tab产生tab位置错乱的问题 #2554
Conversation
滚动不可为负值,负值会导致在不需要滚动的时候,tab位置发生不可预知的顺序变化。
Walkthrough此更改引入了条件检查,以防止在计算位置 Changes
Sequence Diagram(s)(此处不生成序列图,因为更改过于简单。) Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
src/packages/tabs/tabs.taro.tsx
Outdated
|
||
// to < 0 说明不需要进行滚动,页面元素已全部显示出来 | ||
if(to < 0) return | ||
|
||
to = rtl ? -to : to | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修复格式问题并验证逻辑
逻辑正确地防止了不必要的滚动,但需要修复格式问题。
应用以下diff修复格式:
212c212
-
+
214c214
- if(to < 0) return
+ if (to < 0) return
215c215
-
+
218c218
-
+
此外,确保在所有相关场景中验证此逻辑的正确性。
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// to < 0 说明不需要进行滚动,页面元素已全部显示出来 | |
if(to < 0) return | |
to = rtl ? -to : to | |
} | |
// to < 0 说明不需要进行滚动,页面元素已全部显示出来 | |
if (to < 0) return | |
to = rtl ? -to : to | |
Tools
GitHub Check: lint
[failure] 212-212:
Delete··········
[failure] 214-214:
Insert·
[failure] 215-215:
Delete··········
[failure] 218-218:
Delete········
修复格式问题
修改格式问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
src/packages/tabs/tabs.taro.tsx
Outdated
to = rtl ? -to : to | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修复格式问题
调用 nextTick
确保适当地处理滚动动画,但需要修复格式问题。
应用以下diff修复格式:
-
+
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Tools
GitHub Check: lint
[failure] 216-216:
Delete········
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit