-
Notifications
You must be signed in to change notification settings - Fork 278
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): [tabs] Fix more button failure issues in version 3.18.0 #2867
base: release-3.18.0
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces two main changes: a version update in the package.json for the renderless package and modifications to the calcMorePanes function in the tabs module. The version of @opentiny/vue-renderless is updated from 3.18.8 to 3.18.9. Meanwhile, the calcMorePanes function now initializes the currentIndex when unset and uses it to compute the displayed pane count, streamlining the control flow for tab state management. Changes
Sequence Diagram(s)sequenceDiagram
participant TabComponent
participant StateManager
participant PaneList
TabComponent->>StateManager: Invoke calcMorePanes()
StateManager-->>TabComponent: Check if currentIndex == -1
alt currentIndex is -1
TabComponent->>PaneList: Determine pane index by name
PaneList-->>TabComponent: Return pane index
TabComponent->>StateManager: Set currentIndex to returned index
end
TabComponent->>StateManager: Compute showPanesCount using currentIndex
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Walkthrough此PR修复了3.18.0版本中关于更多按钮的一个问题。主要修改集中在 Changes
|
WalkthroughThis PR fixes an issue with more buttons in version 3.18.0. The main modifications are concentrated in the Changes
|
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/index.ts (1)
135-138
: LGTM! Consider these improvements.The initialization of
currentIndex
is correct, but could be improved for better maintainability and type safety.Consider these improvements:
- Use optional chaining as suggested by static analysis
- Add type annotations
- Add a comment explaining the initialization logic
- if (state.currentIndex === -1) { - state.currentIndex = state.panes.findIndex((item) => item.state.paneName === state.currentName) - } - const currentIndex = state.currentIndex < 0 ? 0 : state.currentIndex + // Initialize currentIndex if not set, using the index of the current pane + if (state.currentIndex === -1) { + state.currentIndex = state.panes.findIndex((item) => item.state?.paneName === state.currentName) + } + const currentIndex: number = state.currentIndex < 0 ? 0 : state.currentIndex🧰 Tools
🪛 Biome (1.9.4)
[error] 136-138: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/renderless/package.json
(1 hunks)packages/renderless/src/tabs/index.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/renderless/package.json
🧰 Additional context used
🪛 Biome (1.9.4)
packages/renderless/src/tabs/index.ts
[error] 136-138: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (1)
packages/renderless/src/tabs/index.ts (1)
145-147
: LGTM! The logic for handling tab visibility is now more robust.The changes correctly ensure that the current tab remains visible when it's beyond the visible area, by using index-based comparison instead of name-based comparison.
PR
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: #2819
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit