bar-tabs: :tooltip-fn is called with the tab id, not the tab

Aperta Adatta ai principianti
#384 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
clojure
Ambito
frontend

Direzione di ricerca

Leggi src/re_com/bar_tabs.cljs righe 110-113, dove tooltip-part chiama (tooltip-fn id), e confronta con la versione v2.25.4 in src/re_com/tabs.cljs che passava la map del tab; controlla anche l'args-desc intorno alla riga 45 e come vengono chiamate id-fn/label-fn nello stesso ciclo. Scrivi prima il test che fallisce in test/re_com/bar_tabs_test.cljs, modellato su test/re_com/checkbox_test.cljs, che renderizza horizontal-bar-tabs con :tooltip-fn :hint e verifica che la parte tooltip porti il :hint del tab. Fatto sembra che la tooltip-fn riceva la map del tab e che quel test passi, ma conferma con un maintainer che questa è una regressione prima di applicare la patch.

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

Descrizione

This is a suggested regression. We found it by reading the code during an audit of the :parts and :theme migration (#352). It was not reported from an app. It needs looking over before anyone decides whether it is a regression or an intended change.

What changed

Before, :tooltip-fn was called with the tab map.
See src/re_com/tabs.cljs line 134 at v2.25.4:

tooltip (when tooltip-fn (tooltip-fn t))

Now it is called with the tab id.
See src/re_com/bar_tabs.cljs lines 110 to 113 at 66162a21:

tooltip-part (or (:tooltip t)
                 (when tooltip-fn (tooltip-fn id))
                 (-> props :parts :tooltip-label))

The change arrived with the tabs migration (4f48f8d6, first released in v2.26.1).

Why we think it's a regression

  • The args-desc still gives the type as tab -> string | hiccup and says "given an element of :tabs, returns its tooltip" (bar_tabs.cljs line 45).
  • The documented default is still :tooltip, which only makes sense when applied to a tab map.
  • The sibling functions id-fn and label-fn are still called with the tab map in the same loop.
  • The 2.26.0 changelog does not mention a change to :tooltip-fn.

The default case still works, because (:tooltip t) is tried first.
Only a caller-supplied :tooltip-fn is affected.

Who it affects

Callers that pass their own :tooltip-fn:

[rc/horizontal-bar-tabs
 :model      model
 :tabs       [{:id 1 :label "one" :hint "First"}]
 :tooltip-fn :hint
 :on-change  f]

Before, the tooltip was "First".
Now (:hint 1) is nil, so no tooltip shows.
A function that reads keys from its argument fails in the same silent way.

Suggested fix

Call (tooltip-fn t).
The (:tooltip t) branch can then become the :or default tooltip-fn :tooltip, as at v2.25.4.

A failing test should come first, modelled on test/re_com/checkbox_test.cljs: render bar-tabs with :tooltip-fn :hint and expect the tooltip part to carry the tab's :hint.

Next step

Needs a maintainer to decide whether this is a regression, and to agree the fix.

Lingua principale
Clojure
Stelle
825
Fork
144
Merge medio
2h 42m
PR unite (30g)
1

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 day8/re-com

Tutte le issue di day8/re-com

Issue simili

Altre issue su Clojure

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.