hypothesis / hypothesis/frontend-shared

Popover arrow can be incorrectly positioned if the popover shifts in the x-axis

Open
#2,018 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
8
Forks
5
PR merge metrics
No merged PRs in 30d

Description

We recently implemented support to display an arrow in the Popover, that points to the anchor element.

The implementation was very simplistic/naive: assuming the popover will align to the right or left of the anchor element, we set the arrow in the same side with a small gap.

![Image](https://github.com/user-attachments/assets/d605c0f3-ac4c-4a4e-840a-a43bfc15353a)

![Image](https://github.com/user-attachments/assets/697aaf58-0f10-40e8-902d-26c6eafe17b7)

However, if the space available in the viewport between the anchor and the side to which the Popover is expanding is too narrow to contain the Popover, we shift it in the x-axis to ensure there's no horizontal scroll. This can cause the arrow to no longer point to the anchor element due to its "static" position.

![Image](https://github.com/user-attachments/assets/04c3541a-bb0a-458f-aef9-dd52778e7ce4)

We could do a couple things:

1. More dynamically calculate the position of the arrow, so that it always points to the "center" of the anchor.
2. Reduce the max size of the popover so that it never shifts (this could be conditional if we want). We already cap the size of the popover to the size of the viewport, so we could reduce it even more.

2 might introduce some regression, or produce not obvious differences in behaviors, so it probably makes more sense to go with 1.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.