bug(tooltip): Popover portal does not reset UA border, background, and backdrop when using custom tooltip bodies
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #169 của @stybo — đã đóng, không merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- html, react, typescript
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 850
- Fork
- 56
- Merge trung bình
- 3 giờ 59 phút
- Pull request đã merge (30 ngày)
- 19
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/charts
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Có thể đã có người làm @getdownandcode đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TanStack/charts#211 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
React custom tooltip body shows the previous point for a frame after a pointer moveCó thể đã có người làm @piotrkulpinski đã nhận 5 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Printed charts keep their screen width: resize redraw waits for an animation frameCó thể đã có người làm @piecyk đã nhận 12 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Feature] Readable outside labels for crowded pie and donut chartsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
TanStack/charts#227 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
TanStack/charts#216 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/charts
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Merit-Systems/x402scan#1312 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Native Web
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
digitalfabrik/integreat-app#4517 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
TLS guide repeats certs/ in the certificate directoryCó thể đã có người làm @maheshrijal đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
prometheus/docs#3156 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
medusajs/dtc-starter#90 ·
Maintainer thường phản hồi trong vòng 1 ngày