-
Notifications
You must be signed in to change notification settings - Fork 333
fix(tabs): fixed the tab content cannot be loaded. #3920
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
Conversation
WalkthroughEnhanced tab component initialization logic by introducing a watcher to synchronize current item state when cached item changes, and refactored the mounted lifecycle to conditionally initialize the current item, auto-select the first tab when appropriate, and coordinate swipe observation with scroll positioning. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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: 0
🧹 Nitpick comments (1)
packages/renderless/src/tabs-mf/vue.ts (1)
107-119: Effective initialization fix with minor optimization opportunity.The enhanced
onMountedlogic properly addresses the initialization issue by:
- Observing tab swipe sizes
- Ensuring
currentItemis set from cache- Auto-selecting the first tab when no explicit selection exists (likely the core fix)
- Preserving scroll behavior for explicit selections
The logic is sound and should resolve the reported issue.
Optional: Consolidate redundant initialization
Lines 110-112 duplicate what the watcher at lines 95-103 already does. Consider removing this redundant check since the watcher with
immediate: truehandles the synchronization:🔎 Proposed simplification
nextTick(() => { api.observeTabSwipeSize() - // 确保 currentItem 已设置,如果还没有则使用 cacheCurrentItem - if (!state.currentItem && state.cacheCurrentItem) { - state.currentItem = state.cacheCurrentItem - } // 如果没有 activeName 或 modelValue,且没有选中的 item,则设置第一个 item 为选中 if (!props.activeName && !props.modelValue && state.items.length > 0 && !state.cacheCurrentItem) { api.changeCurrentName(state.items[0].name)Verify: Should auto-selected tabs scroll into view?
When the first tab is auto-selected (line 115), no
scrollTois called, unlike the explicitactiveName/modelValuecases (lines 117-118). Confirm this is the intended UX behavior.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/renderless/src/tabs-mf/vue.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (1)
packages/renderless/src/tabs-mf/vue.ts (1)
94-103: Good reactive synchronization.The watcher effectively keeps
state.currentItemsynchronized withstate.cacheCurrentItemthroughout the component lifecycle. Theimmediate: trueflag ensures any initially-selected item is captured, and the guard condition prevents unnecessary updates.
…wdong/feat-select-docs * 'dev' of https://github.com/opentiny/tiny-vue: (152 commits) feat: add triggering conditions (opentiny#3922) fix:修复初始化tab内容无法加载问题 (opentiny#3920) fix(modal): 修复 modal 组件在 alert, confirm 的弹窗场景下标题图标没有垂直局中的问题 (opentiny#3917) fix(dropdown): add aria information to the dropdown component (opentiny#3913) feat:下拉树支持懒加载 (opentiny#3915) docs: update introduce doc (opentiny#3914) feat:select-wrapper多端示例以及文档 (opentiny#3882) feat:select-wrapper多端 (opentiny#3881) fix(transfer): fix it works when item data receive empty object (opentiny#3912) feat(switch): add width property to support custom switch width (opentiny#3879) fix: optimize the training ground (opentiny#3911) fix(e2e): fix e2e error caused by select refactor (opentiny#3905) feat: automatically trigger updates to the docs document (opentiny#3906) feat: add auto-build-main-module-docs yml (opentiny#3910) fix(split): add saas style (opentiny#3908) fix(grid): fix visible columns change wloud delete insert row (opentiny#3897) chore: add svg icon-layout-vertical (opentiny#3904) fix(saas-icon): add lost icon (opentiny#3903) fix: 修复saas-common 构建报错 (opentiny#3901) fix(grid): add border-top when set border is true (opentiny#3896) ...
PR
fix:修复初始化tab内容无法加载问题
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.