Skip to content

fix(sender): keep consistent gap for sender action tooltips#327

Open
SonyLeo wants to merge 1 commit intoopentiny:developfrom
SonyLeo:fix/sender-tooltip-gap
Open

fix(sender): keep consistent gap for sender action tooltips#327
SonyLeo wants to merge 1 commit intoopentiny:developfrom
SonyLeo:fix/sender-tooltip-gap

Conversation

@SonyLeo
Copy link
Copy Markdown
Collaborator

@SonyLeo SonyLeo commented Apr 17, 2026

Background

Sender 的按钮 tooltip 在 bottom 场景下与触发按钮距离过近,部分情况下会出现 tooltip 贴住按钮的问题。
根因是 demo 中通过全局样式直接修改了 popper 定位结果,导致不同按钮、不同 placement 下的表现不一致。

What changed

  • 移除 demo 中通过 top: -10px !important 修正 tooltip 位置的样式
  • 将 Sender 按钮 tooltip 的 gap 逻辑统一收口到组件内部
  • top / bottom / left / right 处理固定方向间距
  • 统一 submit / clear / upload / voice 的 tooltip 渲染结构
  • 修复 clear 按钮 tooltip 的重复包装问题
  • 增加 --tr-sender-tooltip-gap CSS 变量说明,支持全局样式定制

Result

  • bottom 方向下 tooltip 不再贴住按钮
  • 各默认按钮和增强按钮的 tooltip 间距表现保持一致
  • 不新增 JS API,仅提供 CSS 变量作为样式扩展能力

Verification

  • 检查 submit / clear / upload / voice 的 tooltip 展示
  • 检查 top / bottom / left / right 下的间距表现
  • 验证 docs demo 中不再依赖全局定位补丁

Summary by CodeRabbit

  • Documentation

    • Added documentation for the new --tr-sender-tooltip-gap CSS variable, enabling tooltip spacing customization with an 8px default.
  • Style

    • Refactored tooltip styling system for improved consistency and maintainability across components.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Walkthrough

This PR refactors tooltip styling in sender components by extracting hardcoded styles into a reusable LESS mixin system, introduces a CSS variable for configurable tooltip gap spacing, and enhances tooltip content normalization with wrapper div support. A new tooltip styles file centralizes all mixin definitions, replacing previous scattered declarations.

Changes

Cohort / File(s) Summary
Documentation
docs/demos/sender/actions-config-basic.vue, docs/src/components/sender.md
Removed global style forcing tooltip positioning; added documentation for new --tr-sender-tooltip-gap CSS variable with usage examples and defaults.
Tooltip Styling System
packages/components/src/sender-actions/styles/tooltip.less
New LESS file introducing reusable mixins: gap-aware placement padding, shell reset, inner content constraints, and light variant compositions using theme CSS variables.
Component Style Integration
packages/components/src/sender-actions/action-button/index.vue, packages/components/src/sender-actions/submit-button/index.vue
Replaced hardcoded tooltip popper styles with mixin-based approach; updated selectors to be more specific and leverage new tr-sender-tooltip-light-popper-mixin().
Tooltip Handling Logic
packages/components/src/sender-actions/clear-button/index.vue, packages/components/src/sender-actions/utils/tooltip.ts
Simplified clear-button tooltip binding by removing normalization import; enhanced normalizeTooltipContent() to wrap content in tr-sender-tooltip-inner div with class detection logic for VNode reuse.

Sequence Diagram(s)

Sequence diagrams are not applicable to this change set as it primarily involves styling refactoring, CSS variable introduction, and utility function enhancements without introducing new multi-component interaction flows or significant control flow modifications.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Whiskers twitch with joy, the tooltips now align,
With variables so clever—--tr-sender-tooltip-gap divine!
Mixins shared and mended, no more hardcoded chains,
A refactored warren of styles flowing through the reins. 💫

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: fixing inconsistent tooltip gaps across sender action buttons through a unified gap management system.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@SonyLeo SonyLeo linked an issue Apr 17, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
packages/components/src/sender-actions/utils/tooltip.ts (1)

6-30: Optional: document the shallow VNode check.

hasTooltipInnerClass only inspects the top-level VNode's props.class. Callers who already wrap their tooltip content in tr-sender-tooltip-inner but then nest it further (e.g. return h('div', {}, h('div', { class: TOOLTIP_INNER_CLASS }, content)) from a render function) will still be re-wrapped, leading to a double wrapper. This isn't reachable through current call sites (strings, plain VNodes from defaultActions.*.tooltip / VoiceButton/UploadButton.tooltip), but a brief JSDoc note on renderTooltipInner stating that the inner-class detection is shallow would help future consumers avoid the pitfall.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/components/src/sender-actions/utils/tooltip.ts` around lines 6 - 30,
Add a brief JSDoc on renderTooltipInner explaining that hasTooltipInnerClass
only checks the top-level VNode.props.class (it is a shallow check and does not
traverse nested children or deeper VNode trees), so callers who nest a node with
TOOLTIP_INNER_CLASS inside another element will still be re-wrapped; update the
comments above renderTooltipInner and/or hasTooltipInnerClass (referencing those
exact function names and TOOLTIP_INNER_CLASS) to state this limitation and
recommend that callers place the TOOLTIP_INNER_CLASS on the outermost node if
they want to avoid automatic wrapping.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/components/src/sender-actions/utils/tooltip.ts`:
- Around line 6-30: Add a brief JSDoc on renderTooltipInner explaining that
hasTooltipInnerClass only checks the top-level VNode.props.class (it is a
shallow check and does not traverse nested children or deeper VNode trees), so
callers who nest a node with TOOLTIP_INNER_CLASS inside another element will
still be re-wrapped; update the comments above renderTooltipInner and/or
hasTooltipInnerClass (referencing those exact function names and
TOOLTIP_INNER_CLASS) to state this limitation and recommend that callers place
the TOOLTIP_INNER_CLASS on the outermost node if they want to avoid automatic
wrapping.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3889678a-4caa-4bf4-9924-30791caad4e0

📥 Commits

Reviewing files that changed from the base of the PR and between 6a8bf29 and fa70659.

📒 Files selected for processing (7)
  • docs/demos/sender/actions-config-basic.vue
  • docs/src/components/sender.md
  • packages/components/src/sender-actions/action-button/index.vue
  • packages/components/src/sender-actions/clear-button/index.vue
  • packages/components/src/sender-actions/styles/tooltip.less
  • packages/components/src/sender-actions/submit-button/index.vue
  • packages/components/src/sender-actions/utils/tooltip.ts
💤 Files with no reviewable changes (1)
  • docs/demos/sender/actions-config-basic.vue

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

✅ Preview build completed successfully!

Click the image above to preview.
Preview will be automatically removed when this PR is closed.

@github-actions
Copy link
Copy Markdown
Contributor

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.

【sender】【style】tooltipPlacement bottom offset

1 participant