bug(tooltip): Popover portal does not reset UA border, background, and backdrop when using custom tooltip bodies
I maintainer di solito rispondono entro 1 giorno
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
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:
- 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.
- Lingua principale
- TypeScript
- Stelle
- 842
- Fork
- 53
- Merge medio
- 4h 40m
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/charts
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Forse già presa @getdownandcode l’ha presa 4 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TanStack/charts#211 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Printed charts keep their screen width: resize redraw waits for an animation frameForse già presa @piecyk l’ha presa 4 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
[Feature] Readable outside labels for crowded pie and donut chartsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
TanStack/charts#227 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
TanStack/charts#216 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/charts
Issue simili
-
The inspector never shows the instances field, so scaling out is unreachableForse già presa @Mrkewl l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
xevrion/breakscale#96 ·
I maintainer di solito rispondono entro 4 giorni
-
Object parameters lose their structure when resources is enabledForse già presa @asts-top l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
rossant/awesome-math#199 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
jaegertracing/jaeger-ui#4618 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
mifi/lossless-cut#3125 ·
I maintainer di solito rispondono entro 1 giorno