Nested buttons from TooltipTrigger without asChild

Đang mở Phù hợp với người mới
#5,302 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đá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
73/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
accessibility, frontend

Hướng nghiên cứu

Bắt đầu với packages/client/src/components/ui/tooltip.tsx và kiểm tra các vị trí sử dụng TooltipTrigger được liệt kê trong merge-charges/index.tsx, download-csv-button.tsx, close-document-button.tsx, preview-document-modal.tsx và template-manager.tsx. Kiểm tra các bài kiểm thử hoặc story hiện có của component, sau đó xác minh trang All Charges và các tab Charges và Balance không có cảnh báo lồng nhau, đồng thời tooltip hoạt động như mong đợi trên các nút bị vô hiệu hóa. Hoàn tất khi các cảnh báo đó không còn và có bài kiểm thử hoặc story bao quát trường hợp tooltip trên nút bị vô hiệu hóa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

Some uses of the shadcn TooltipTrigger (packages/client/src/components/ui/tooltip.tsx) omit asChild. The Radix trigger renders its own <button>, so when it wraps a <Button> the page contains a button inside a button. React logs a validateDOMNesting warning, and the markup is invalid HTML (focus and click handling can misbehave).

Confirmed in a browser:

  • packages/client/src/components/common/merge-charges/index.tsx (MergeChargesButton): DialogTrigger → TooltipTrigger → Button, three buttons deep. It shows on every charges table with merge selection (All Charges, business and tax category Charges tabs, …).
  • packages/client/src/components/common/buttons/download-csv-button.tsx (DownloadCSVButton): TooltipTrigger → Button. It shows on business-ledger balance views (the business and tax category Balance tabs and the full-screen ledger).

Other <TooltipTrigger> uses without asChild to check:

  • packages/client/src/components/common/buttons/close-document-button.tsx (two)
  • packages/client/src/components/common/modals/preview-document-modal.tsx
  • packages/client/src/components/reports/dynamic-report/dialogs/template-manager.tsx

Fix

Use <TooltipTrigger asChild> around the button. A disabled <button> fires no pointer events, so where the tooltip has to show while the button is disabled (the merge button explains why merging is unavailable; the CSV button says "Preparing download…"), wrap the button in a <span> and make the span the asChild trigger. Nested triggers (DialogTrigger inside TooltipTrigger) each need asChild.

Done when

No validateDOMNesting warning on the All Charges page or the Charges and Balance tabs. The tooltips still show, including on disabled buttons, and there is a test or story for the disabled-tooltip case.

Ngôn ngữ chính
TypeScript
Star
30
Fork
10
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
276

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Urigo/accounter-fullstack

Tất cả issue của Urigo/accounter-fullstack

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.