bug(tooltip): Popover portal does not reset UA border, background, and backdrop when using custom tooltip bodies
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 20/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- html, react, typescript
调研方向
Start with packages/charts-core/tooltip-portal.ts and tooltip.ts, where the issue identifies the popover resets and inline tooltip styles. Check how renderTooltipBody is handled and run the relevant chart-core tests, if available. Done when custom tooltip bodies no longer inherit unwanted wrapper card styles and the popover backdrop is hidden; a linked pull request is already open.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When using @tanstack/charts with portal and a custom React tooltip body (renderTooltipBody), the outer container element renders an unwanted border, white/canvas background, padding, box shadow, and in some browsers a backdrop.
This happens due to two issues in packages/charts-core:
- Missing Popover UA Resets: In
tooltip-portal.ts, whenelement.setAttribute("popover", "manual")is called, modern browsers apply their default User-Agent stylesheet rules for:popover-open(border: 2px solid,background-color: Canvas,padding: 0.25em) and create a::backdroppseudo-element.tooltip-portal.tsonly setsposition: fixed,margin: 0, but does not neutralizeborder,background,outline,padding, or::backdrop. - Hardcoded Inline Card Styles on Custom Tooltips: In
tooltip.ts(createTooltip),tooltipElement.stylehas hardcoded inline styles (background: Canvas,border: 1px solid ...,boxShadow: ...,padding: ...). When a consumer provides their own<ChartTooltip />component viarenderTooltipBody, these high-specificity inline styles leak around the custom card, forcing users to use!importantCSS overrides.
Minimal Reproduction
import { defineChart, lineY } from "@tanstack/charts";
import { Chart } from "@tanstack/charts/react/tooltip";
import { portal } from "@tanstack/charts/tooltip/portal";
import { tooltip } from "@tanstack/charts/tooltip";
const chart = defineChart({
marks: [lineY(data, { x: "time", y: "value" })],
tooltip: {
portal,
use: tooltip,
},
});
export function TelemetryChart() {
return (
<Chart
definition={chart}
renderTooltipBody={({ points }) => (
// Custom styled tooltip card
<div className="rounded-lg border border-zinc-200 bg-zinc-900 p-2 text-white">
Value: {points[0].yValue}
</div>
)}
/>
);
}
Expected Behavior
When renderTooltipBody is passed, or when portal uses the HTML Popover API:
- The outer popover wrapper element (
.ts-chart-tooltip) should act as an unstyled positioning anchor without default card borders, canvas backgrounds, or padding. - The popover's
::backdropshould be hidden by default (display: none).
Actual Behavior
The custom tooltip card is wrapped in a container that displays:
- The browser's native popover border and
Canvasbackground color. - TanStack Charts' default card padding, border, and box-shadow inline styles.
Suggested Fix
- In
tooltip-portal.ts, reset UA popover styles (border: "none",background: "transparent",padding: "0",outline: "none") and inject a backdrop reset stylesheet. - In
tooltip.ts, resettooltipElement.stylewhencustomis true (renderTooltipBodyis active).
I am opening a PR with this fix.
- 主要语言
- TypeScript
- 星标
- 842
- 派生
- 53
- 平均合并
- 4 小时 40 分钟
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/charts 的其他 Issue
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`可能已有人在做 @getdownandcode 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug] Printed charts keep their screen width: resize redraw waits for an animation frame可能已有人在做 @piecyk 于 3 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 25/100
维护者通常 1 天内回复
-
[Feature] Readable outside labels for crowded pie and donut charts可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 42/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 57/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
polarsource/polar#15580 ·
维护者通常 1 天内回复
-
accepted bug via-triage
难度 2/5 1-3 小时 新手友好度 69/100
pingdotgg/t3code#20931 · 1 条评论 ·
维护者通常 1 天内回复
-
bug/1-unconfirmed kind/bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
-
难度 2/5 1-3 小时 新手友好度 72/100
ranxianglei/billion-context#3583 ·
维护者通常 1 天内回复