Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa
#168 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@stybo ci sta già lavorando.

Dal 6/10/2026.

  • #169 di @stybo — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
html, react, typescript
Ambito
design, frontend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
842
Fork
53
Merge medio
4h 40m
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/charts

Tutte le issue di TanStack/charts

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.