Tooltip arrow is not centered on the highlighted element and `arrowSize` does not control its rendered size

Aperta
#354 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
react-native, typescript
Ambito
mobile

Direzione di ricerca

Inizia individuando il posizionamento della freccia del tooltip e il rendering del triangolo in [email protected], quindi traccia come vengono utilizzati il layout dell'elemento evidenziato e arrowSize. Il lavoro è completato quando la freccia è centrata sull'elemento evidenziato, utilizza l'arrowSize configurato e rimane completamente all'interno dello schermo vicino ai bordi.

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

Descrizione

In [email protected], the tooltip arrow is positioned at a fixed margin from either the left or right tooltip edge:

arrow.right = tooltip.right + margin;

// or

arrow.left = tooltip.left + margin;

The side is selected based on which half of the screen contains the highlighted element. However, the arrow position does not use the element's actual horizontal center. This causes the arrow to appear near a tooltip corner instead of pointing at the highlighted element, especially for wide targets such as cards, banners, and navigation areas.

The arrowSize prop is also used in the positioning calculations, but the rendered triangle keeps the hardcoded ARROW_SIZE value as its borderWidth. Therefore, a custom arrowSize can produce a mismatch between the calculated and rendered arrow sizes.

Expected behavior:

  • The arrow should point at the horizontal center of the highlighted element.
  • The rendered triangle should use the value provided through arrowSize.
  • The arrow should remain inside the screen when the highlighted element is close to an edge.

Potential solution:

arrow.borderWidth = arrowSize;

arrow.left = Math.max(
  0,
  Math.min(
    center.x - arrowSize,
    newMeasuredLayout.width - arrowSize * 2,
  ),
);

The existing arrow.left and arrow.right assignments based on the tooltip edge would be removed. center.x - arrowSize aligns the middle of the triangle with the middle of the highlighted element, while the bounds keep the complete arrow visible on screen.

Lingua principale
TypeScript
Stelle
2.4k
Fork
425
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

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 mohebifar/react-native-copilot

Tutte le issue di mohebifar/react-native-copilot

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.