Nested buttons from TooltipTrigger without asChild

Aperta Adatta ai principianti
#5,302 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
73/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript

Direzione di ricerca

Inizia da packages/client/src/components/ui/tooltip.tsx ed esamina gli utilizzi di TooltipTrigger indicati in merge-charges/index.tsx, download-csv-button.tsx, close-document-button.tsx, preview-document-modal.tsx e template-manager.tsx. Controlla i test o le storie esistenti del componente, quindi verifica che la pagina All Charges e le schede Charges e Balance non presentino avvisi di annidamento e che i tooltip sui pulsanti disabilitati funzionino correttamente. Il lavoro è completato quando gli avvisi sono scomparsi e un test o una storia copre il caso del tooltip su un pulsante disabilitato.

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

Descrizione

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.

Lingua principale
TypeScript
Stelle
30
Fork
10
Merge medio
2g 12h
PR unite (30g)
276

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 Urigo/accounter-fullstack

Tutte le issue di Urigo/accounter-fullstack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.