Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

bug(tooltip): Popover portal does not reset UA border, background, and backdrop when using custom tooltip bodies

已关闭
#168 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@stybo 已经在做这个了。

开始于 2026年10月6日。

  • #169 来自 @stybo —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
html, react, typescript
领域
design, frontend

调研方向

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:

  1. Missing Popover UA Resets: In tooltip-portal.ts, when element.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 ::backdrop pseudo-element. tooltip-portal.ts only sets position: fixed, margin: 0, but does not neutralize border, background, outline, padding, or ::backdrop.
  2. Hardcoded Inline Card Styles on Custom Tooltips: In tooltip.ts (createTooltip), tooltipElement.style has hardcoded inline styles (background: Canvas, border: 1px solid ..., boxShadow: ..., padding: ...). When a consumer provides their own <ChartTooltip /> component via renderTooltipBody, these high-specificity inline styles leak around the custom card, forcing users to use !important CSS 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:

  1. The outer popover wrapper element (.ts-chart-tooltip) should act as an unstyled positioning anchor without default card borders, canvas backgrounds, or padding.
  2. The popover's ::backdrop should 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 Canvas background color.
  • TanStack Charts' default card padding, border, and box-shadow inline styles.

Suggested Fix
  1. In tooltip-portal.ts, reset UA popover styles (border: "none", background: "transparent", padding: "0", outline: "none") and inject a backdrop reset stylesheet.
  2. In tooltip.ts, reset tooltipElement.style when custom is true (renderTooltipBody is active).

I am opening a PR with this fix.

主要语言
TypeScript
星标
842
派生
53
平均合并
4 小时 40 分钟
30 天内合并 PR
16

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/charts 的其他 Issue

查看 TanStack/charts 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。