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

Abierto
#354 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
react-native, typescript
Área
mobile

Línea de trabajo

Comienza localizando el posicionamiento de la flecha del tooltip y el renderizado del triángulo en [email protected]; después, sigue cómo se utilizan el layout del elemento resaltado y arrowSize. Se considera terminado cuando la flecha queda centrada sobre el elemento resaltado, utiliza el arrowSize configurado y permanece completamente dentro de la pantalla cerca de los bordes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
2.4k
Forks
425
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de mohebifar/react-native-copilot

Todos los issues de mohebifar/react-native-copilot

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.