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

Đang mở
#354 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
react-native, typescript
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu bằng cách xác định vị trí của mũi tên tooltip và cách render hình tam giác trong [email protected], sau đó theo dõi cách layout của phần tử được làm nổi bật và arrowSize được sử dụng. Hoàn thành có nghĩa là mũi tên được căn giữa trên phần tử được làm nổi bật, sử dụng arrowSize đã cấu hình và vẫn nằm hoàn toàn bên trong màn hình khi ở gần các cạnh.

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

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
2.4k
Fork
425
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

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

Tất cả issue của mohebifar/react-native-copilot

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.