Repository navigation
[v4] Popup: let field-anchored popups scroll away with their trigger instead of pinning to the viewport #19400
VeiaG
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The current behaviour
In Payload 4,
Popupusesposition: fixed, recomputes its position on everyscroll, and clampstopinto the viewport (Popup/index.tsx#L428-L429):While the trigger is on screen, the popup follows it. Once the page scrolls the trigger out of view, the popup stays pinned to the top or bottom edge of the viewport. It's detached from its trigger and floats over unrelated fields.
Payload 3 positioned the popup in page coordinates (3.x
Popup/index.tsx#L187:triggerRect.bottom + window.scrollY + offset, with no vertical clamp), so it scrolled away together with its trigger.Why it matters
Pinning is a good default for menus opened from fixed chrome, like the header or the document controls. For a popup anchored to a form field, though, it reads as a bug: the panel belongs to a field the editor can no longer see.
ReactSelect's menu, the other dropdown used by native fields, scrolls with its field.I hit this while porting plugin with custom fields to v4.
Proposal
An opt-in prop that ties the vertical position to the trigger, for example:
PopupPropsalready declaresboundingRef?: React.RefObject<HTMLElement>, but nothing in the v4Popupreads it. It could carry this instead: clamp to that element's rect instead of the viewport. Passing the field's own wrapper would then give the "follow the trigger" behaviour.All reactions