Skip to content

Conversation

li-jia-nan
Copy link
Member

@li-jia-nan li-jia-nan commented Oct 6, 2025

Summary by CodeRabbit

  • 新功能
    • 支持语义化 classNames/styles(取代旧的 className/style),可按语义键定制各部分外观。
    • 新增 "close" 语义键,可单独定制关闭按钮样式。
    • 弹出层样式改为通过 styles.popup 提供,提升主题一致性与可定制性。
  • 修复
    • 选中标签的自动滚动行为更稳定,避免因选择项标识变化遗漏滚动触发。

Copy link

vercel bot commented Oct 6, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
tabs Ready Ready Preview Comment Oct 6, 2025 10:22pm

Copy link
Contributor

Summary of Changes

Hello @li-jia-nan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a new feature that provides enhanced control over the visual presentation of tab components. It refactors the styling approach by introducing semantic names for different parts of a tab, such as the main item and its close button, allowing developers to apply distinct class names and styles more precisely. This change involves updating component props to accept structured style objects rather than single string/object values. Additionally, a minor adjustment was made to the tab navigation logic to ensure the currently selected tab is always brought into view.

Highlights

  • Granular Styling: Introduced a new mechanism for more granular styling of tab components, allowing specific class names and styles to be applied to the tab item and its close button.
  • Tab Close Button Customization: The 'close' button of a tab can now be targeted semantically for custom styling, enhancing flexibility in UI design.
  • Improved Tab Navigation: Updated the dependency array for a useEffect hook in OperationNode.tsx to ensure the selected tab item remains visible when selectedItemId changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.98%. Comparing base (585b2a1) to head (90d2298).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #915      +/-   ##
==========================================
- Coverage   98.98%   98.98%   -0.01%     
==========================================
  Files          18       18              
  Lines         789      788       -1     
  Branches      237      233       -4     
==========================================
- Hits          781      780       -1     
  Misses          8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a 'semantic close' feature, allowing for more granular styling of the close button on tabs by adding 'close' to SemanticName and plumbing through classNames.close and styles.close to the TabNode component. The changes are well-structured and consistently applied across the affected files. I've included one suggestion to improve the maintainability of how styles are passed down to child components.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link

coderabbitai bot commented Oct 6, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

本次变更将 Tab 系列组件的样式接口改为语义化 classNames/styles(新增语义键 close),并在 OperationNode 中用派生的 selectedItemId 调整滚动到视图的副作用依赖项。

Changes

Cohort / File(s) Summary of changes
Tab 语义化样式 API
src/TabNavList/TabNode.tsx, src/TabNavList/index.tsx, src/Tabs.tsx
- 将单一 className/style 替换为按 SemanticName 分组的 classNames?: Partial<Record<SemanticName, string>>styles?: Partial<Record<SemanticName, React.CSSProperties>>
- 在 TabNode 与上层传递中使用 classNames.item/styles.item;关闭按钮使用 classNames.close/styles.close
- 在 src/Tabs.tsx 中向 SemanticName 添加 'close'
OperationNode:样式与滚动依赖
src/TabNavList/OperationNode.tsx
- 移除公开 popupStyle,改为通过 styles?.popup 传递 overlay 样式;给下拉移除按钮应用 classNames?.closestyles?.close
- 引入派生 selectedItemId(基于 selectedKeypopupId),并将 useEffect 的依赖从 [selectedKey] 改为 [selectedItemId, selectedKey],用于精确触发滚动定位与 aria-activedescendant。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Nav as TabNavList
  participant Tab as TabNode
  participant Op as OperationNode
  participant DOM as DOM (scroll/overlay)

  Note over Nav,Tab: 样式/类名以语义组传递
  Nav->>Tab: props { classNames, styles, ... }
  Nav->>Op: props { classNames, styles, ... }

  Note over Op,DOM #D3F8E2: 选中项变化触发滚动(依赖 selectedItemId)
  Op->>Op: compute selectedItemId (from selectedKey + popupId)
  Op->>DOM: scrollIntoView(selectedItemId) (when selectedItemId or selectedKey changes)
  Op->>DOM: open overlay with overlayStyle = styles?.popup
  Op->>DOM: remove button uses class = classNames?.close, style = styles?.close
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • zombieJ

Poem

我是小兔写新花,
classNames 排队来把家;
item 与 close 各就位,styles 穿新装。
选中跳转轻轻滑,视窗一瞥得安康。 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 该标题提及了对“close”语义样式的适配,这与 PR 中新增 SemanticName 类型并在 OperationNode 和 TabNode 中扩展 classNames/styles API 的改动直接相关,它简洁地捕捉了这一关键变更的要点。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch semantic-close

📜 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 463288f and 90d2298.

📒 Files selected for processing (3)
  • src/TabNavList/OperationNode.tsx (6 hunks)
  • src/TabNavList/TabNode.tsx (6 hunks)
  • src/TabNavList/index.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/TabNavList/OperationNode.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
src/TabNavList/TabNode.tsx (1)
src/Tabs.tsx (1)
  • SemanticName (38-38)
🔇 Additional comments (7)
src/TabNavList/TabNode.tsx (5)

5-5: LGTM!

正确引入了 SemanticName 类型以支持新的语义化样式 API。


27-28: LGTM!

新增的 classNamesstyles 属性正确使用了语义化键值(SemanticName),替代了原有的扁平化 classNamestyle 属性,提升了组件的主题定制能力。


87-93: LGTM!

Tab 容器正确应用了语义化样式:

  • 使用 classNames?.item 合并到 className
  • 使用 styles?.item 设置内联样式

这与新的语义化主题 API 保持一致。


134-135: LGTM!

移除按钮正确使用了新增的 close 语义化键:

  • classNames?.close 用于 class
  • styles?.close 用于内联样式

src/Tabs.tsx 中新增的 'close' 语义名称定义对应。


147-147: LGTM!

显式的函数类型检查提升了代码的健壮性,避免了潜在的类型错误。

src/TabNavList/index.tsx (2)

438-442: LGTM!

styles 对象的传递方式正确:

  • 通过展开运算符 ...styles 传递所有语义化样式
  • 仅覆盖 item 属性以处理首个 Tab(无间距)与后续 Tab(有间距)的差异

这已经符合之前评审意见的建议,保持了与 classNames 的一致性。


645-650: LGTM!

OperationNode 的属性传递正确:

  • className 使用 clsx 条件性地应用隐藏样式类
  • classNamesstyles 完整传递以支持语义化主题

TabNode 的处理方式保持一致。


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
src/TabNavList/OperationNode.tsx (1)

164-171: 优化 Effect 依赖与空值保护

仅依赖 selectedItemId 即可,且在其为空时应短路,避免 getElementById(null) 的无效查询与多余重渲染。

-  useEffect(() => {
-    // We use query element here to avoid React strict warning
-    const ele = document.getElementById(selectedItemId);
-    if (ele && ele.scrollIntoView) {
-      ele.scrollIntoView(false);
-    }
-  }, [selectedItemId, selectedKey]);
+  useEffect(() => {
+    if (!selectedItemId) return;
+    // We use query element here to avoid React strict warning
+    const ele = document.getElementById(selectedItemId);
+    ele?.scrollIntoView?.(false);
+  }, [selectedItemId]);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 585b2a1 and 463288f.

📒 Files selected for processing (4)
  • src/TabNavList/OperationNode.tsx (1 hunks)
  • src/TabNavList/TabNode.tsx (5 hunks)
  • src/TabNavList/index.tsx (1 hunks)
  • src/Tabs.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/TabNavList/TabNode.tsx (1)
src/Tabs.tsx (1)
  • SemanticName (38-38)
🔇 Additional comments (2)
src/TabNavList/index.tsx (1)

438-442: 完整透传 styles,仅覆写 item,做法正确

这样保持与 classNames 的一致性,并为未来扩展留余地;同时用户样式优先级覆盖内置间距,语义清晰。

src/TabNavList/TabNode.tsx (1)

84-94: 语义化样式接入到位

  • 根节点合并 classNames.item 与 styles.item
  • 移除按钮使用 classNames.close 与 styles.close

实现与扩展后的 SemanticName 完整对齐,样式优先级与可定制性良好。

Also applies to: 128-136

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