Skip to content

fix(web-ui): prevent sticky hover tooltips on touch and coarse-pointer devices - #1275

Merged
iruriQ merged 1 commit into
mainfrom
fix/issue-1267
Nov 27, 2026
Merged

iruriQ merged 1 commit into
mainfrom
fix/issue-1267

Conversation

@iruriQ

@iruriQ iruriQ commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1267

In mobile touch mode (390×844), tapping top-bar controls such as the sidebar toggle (「打开侧边栏」) could leave a hover Tooltip stuck over the conversation title after entering a session.

Root Cause

  • Tooltip.tsx split hover handling across onPointerEnter (gated on phone) and onMouseEnter (active whenever !phone), allowing synthesized touch compatibility mouse events and coarse-pointer/hover-none pointer events to open hover tooltips.
  • Clicking/pressing an anchor did not dismiss on pointerdown and left triggers.current.hover set on click.
  • onFocus did not check :focus-visible and only guarded data-dsh-automatic-focus when phone was true.

Changes

  • apps/web-ui/packages/client/ui-primitives/src/Tooltip.tsx:
    • Use unified onPointerEnter / onPointerLeave and ignore hover triggers when pointerType === "touch" or window.matchMedia("(hover: none), (pointer: coarse)").matches.
    • Dismiss non-openOnClick tooltips on onPointerDown and clear both hover and focus triggers in onClick.
    • Gate onFocus tooltips on :focus-visible and ignore data-dsh-automatic-focus regardless of viewport.
    • Mark keyboard-focused bubbles with data-focus while preserving openOnClick (data-pinned) and nested TooltipSuppression.
  • apps/web-ui/packages/client/ui-primitives/src/Tooltip.module.css:
    • Add @media (hover: none), (pointer: coarse) guard hiding hover-only bubbles (.bubble:not([data-pinned]):not([data-focus])) without affecting openOnClick or :focus-visible tooltips.

No visual changes: suppresses stale hover-only tooltips on touch/coarse-pointer devices without altering desktop tooltip layout, styling, or keyboard :focus-visible behavior.

Validation

  • npx prettier --check apps/web-ui/packages/client/ui-primitives/src/Tooltip.tsx apps/web-ui/packages/client/ui-primitives/src/Tooltip.module.css
  • npx eslint apps/web-ui/packages/client/ui-primitives/src/Tooltip.tsx
  • npx tsc -b packages/shared-contracts packages/desktop-control && npm run build:web:ui
  • npx tsc --noEmit -p apps/web-ui/tsconfig.json

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Summary

Summary by CodeRabbit

  • Bug 修复
    • 优化触屏及粗指针设备上的提示气泡行为:避免仅因触摸或自动聚焦而显示气泡,并在指针按下时关闭普通提示气泡。
    • 键盘焦点仍可按需显示提示气泡。

Tooltip 现在会识别粗指针、无悬停能力的设备及 :focus-visible 状态。触控或指针按下时,组件会按新的规则抑制或关闭气泡;样式也会在触控设备上隐藏未固定且非焦点触发的气泡。

Changes: Tooltip 触控与焦点交互

Layer / File(s) Summary
触发状态与气泡显示
apps/web-ui/packages/client/ui-primitives/src/Tooltip.tsx, apps/web-ui/packages/client/ui-primitives/src/Tooltip.module.css
组件新增粗指针、无悬停能力及 :focus-visible 检测,并记录气泡是否由焦点触发。触控设备上的指针进入不再显示气泡;非 openOnClick 模式下,指针按下会清除触发状态并关闭气泡。自动焦点、指针输入或不匹配 :focus-visible 时不显示气泡。触控设备上,未固定且非焦点触发的气泡会被隐藏。

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: bytepioneer-ai

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@iruriQ
iruriQ merged commit 1335313 into main Nov 27, 2026
5 of 8 checks passed
@iruriQ
iruriQ deleted the fix/issue-1267 branch November 27, 2026 01:09
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.

[Bug] 移动端触控点击顶栏按钮后 Tooltip 残留遮挡会话标题

2 participants