-
Notifications
You must be signed in to change notification settings - Fork 330
fix(tabs): Fix the issue of using both overflow-title and with-close simultaneously #3709
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
WalkthroughReorders variable declarations in a tab title mouseenter handler to occur after a tooltip-config guard. Updates tabs CSS: makes non-stretch header tab item titles block-level with width 100%, and performs minor formatting/brace adjustments. No public API changes. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant T as Tab Title
participant H as Mouseenter Handler
participant TT as Tooltip
U->>T: hover
T->>H: handleTitleMouseenter(event)
alt tooltipConfig disabled/guarded
H-->>T: return early (no work)
else tooltipConfig enabled
H->>H: resolve event target (dom) and title el (el)
H->>H: check overflow (el.scrollWidth > el.offsetWidth)
alt overflow
H->>TT: configure and show tooltip
else no overflow
H-->>TT: ensure tooltip hidden
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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 (2)
packages/renderless/src/tab-nav/index.ts (1)
437-452: Anchor tooltip to currentTarget; avoid bubbling to child nodes (e.g., close icon)Using
e.currentTargetis more robust thane.targetfor mouseenter. Also cast toHTMLElementfor clarity.Apply:
- const dom = e.target - // 以下逻辑与aui不同,tiny不能通过dom宽度判断是否超出隐藏 - const el = title?.el + const dom = (e.currentTarget || e.target) as HTMLElement + // 以下逻辑与aui不同,tiny不能通过dom宽度判断是否超出隐藏 + const el = title?.el as HTMLElement | undefinedpackages/theme/src/tabs/index.less (1)
118-124: Use flex growth + min-width: 0 instead of width: 100% in flex row
width: 100%on a flex item can push/overlap the close icon. Let the title grow to available space and truncate correctly.Apply:
- .@{tabs-prefix-cls}__item__title { - display: block; - width: 100%; + .@{tabs-prefix-cls}__item__title, + .@{tabs-prefix-cls}__item-title { + display: block; + flex: 1 1 auto; + min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/renderless/src/tab-nav/index.ts(1 hunks)packages/theme/src/tabs/index.less(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 (2)
packages/renderless/src/tab-nav/index.ts (1)
437-440: Good: defer DOM reads until after tooltipConfig guardThis avoids unnecessary DOM access and minor work on early-return paths.
packages/theme/src/tabs/index.less (1)
118-124: Confirm BEM selector actually matches DOMBoth .@{tabs-prefix-cls}__item__title (double-underscore) and .@{tabs-prefix-cls}__item-title (single-hyphen, from the nested &__item &-title) are present in packages/theme/src/tabs/index.less; repository search returned no template/markup usages (rg skipped files). Verify which class the markup uses and remove the unused selector to avoid dead CSS.
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: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Style
Refactor