Skip to content

Revert "fix(tabs): Optimize multi terminal caching logic, add add add delete operations to trigger sub component destruction and reconstruction logic" #3606

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

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Jul 24, 2025

Reverts #3601

Summary by CodeRabbit

  • Refactor
    • Improved the rendering logic for tab panels, removing the use of a cache and optimizing how active tab content is displayed and preserved.
    • Simplified internal state management for tabs.

No changes to public APIs or user-facing controls.

Copy link

coderabbitai bot commented Jul 24, 2025

Walkthrough

This change removes the tab panel caching mechanism from the mobile-first tabs component. The state object no longer includes tabPanelCache or includeNames. Instead of caching and toggling multiple tab panels, only the currently active tab's panel is rendered and wrapped in a KeepAlive component to preserve its state.

Changes

File(s) Change Summary
packages/renderless/src/tabs-mf/vue.ts Removed tabPanelCache and includeNames from state initialization.
packages/vue/src/tabs/src/mobile-first.vue Refactored tab panel rendering: removed cache logic, now renders only the active tab in KeepAlive.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TabsComponent
    participant KeepAlive
    participant TabPanel

    User->>TabsComponent: Selects a tab
    TabsComponent->>TabsComponent: Identify active tab
    TabsComponent->>TabPanel: Create vnode for active tab
    TabsComponent->>KeepAlive: Wrap TabPanel vnode
    KeepAlive->>TabPanel: Preserve state
    TabsComponent-->>User: Renders only active tab panel
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Poem

A cache once lived, now swept away,
Only the active tab gets to play.
Wrapped in KeepAlive, its state will stay,
No more toggling panels in the fray!
The code is lean, the logic clear—
Hopping forward, tabs persevere! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/vue/src/tabs/src/mobile-first.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

packages/renderless/src/tabs-mf/vue.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 532c8a7 and 0c35127.

📒 Files selected for processing (2)
  • packages/renderless/src/tabs-mf/vue.ts (1 hunks)
  • packages/vue/src/tabs/src/mobile-first.vue (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/vue/src/tabs/src/mobile-first.vue (1)

Learnt from: Davont
PR: #2513
File: packages/vue/src/huicharts/huicharts-histogram/src/chart-histogram.vue:33-36
Timestamp: 2024-11-25T03:43:05.285Z
Learning: 在 Tiny Vue 代码库中,使用 chart-core 中的 huiChartOption 的组件,不应在其 data 中定义 huiChartOptionoption,而是应该依赖 chart-core 提供的 huiChartOption

🔇 Additional comments (3)
packages/renderless/src/tabs-mf/vue.ts (1)

48-48: LGTM! Clean state simplification.

The removal of caching-related state properties (tabPanelCache and includeNames) correctly simplifies the state object back to its original form, leaving only the essential tabsId increment.

packages/vue/src/tabs/src/mobile-first.vue (2)

3-3: Appropriate import addition for the new rendering approach.

The KeepAlive import is correctly added to support the simplified tab rendering logic that preserves component state.


43-67: Verify simplified tab rendering behavior and state preservation

We’ve replaced the old multi-tab caching mechanism with a single-active-tab render wrapped in KeepAlive. Since no existing tests cover tab caching or state retention, please manually verify that:

  • Performance remains acceptable when switching tabs (benchmark render time and responsiveness).
  • Component state is preserved for inactive tabs when you switch back.
  • Memory usage does not regress due to more frequent component mounts/unmounts.

If possible, add automated tests or benchmarks for caching/state‐preservation to guard against future regressions.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-3601-fix/mobile-first-tabs-20250718

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@zzcr zzcr merged commit 875322c into dev Jul 24, 2025
10 of 11 checks passed
@zzcr zzcr deleted the revert-3601-fix/mobile-first-tabs-20250718 branch July 24, 2025 06:46
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