callstack / callstack/react-native-paper

🚀 Feature Request: Preserve Anchor Alignment in Upward-Opening `Menu` with Dynamic Content

Aperta
#4,747 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
feature request
Lingua principale
TypeScript
Stelle
14.5k
Fork
2.2k
Merge medio
5g 23h
PR unite (30g)
12

Descrizione

## Description

When using the `Menu` component from `react-native-paper` as a dropdown in an autocomplete-style UI, there is a UX inconsistency when the menu opens **upwards** from its anchor and its content is **dynamically filtered**.

Currently, when filtering the list while the menu is already open (e.g., user types to refine suggestions):

- The menu shrinks to fit the updated result set,
- But it does **not maintain a fixed position relative to its anchor**,
- Resulting in the menu shifting upward, giving the impression that it is disconnected from its triggering anchor.

This behavior is especially noticeable in autocomplete scenarios, where the menu’s height often changes as the user types.

---

## Proposed Behavior

It would be beneficial if the `Menu` component:

- Could maintain **visual alignment with its anchor**, even when the content height changes,
- Especially when opened **upward** due to limited space below the anchor,
- Adjusted its top boundary instead of bottom when opened upward, preserving anchor binding.

This feature would greatly enhance the usability of the `Menu` in dynamic UIs, such as autocomplete components or filterable lists.

---

## Suggested Enhancements

- Add a prop like `preserveAnchorAlignment` or `stickToAnchor` that keeps the menu visually connected to the anchor during dynamic content changes.
- Internally detect when the menu opens upward, and adjust only the top boundary to maintain anchor alignment when the height changes.
- Optionally expose a more flexible positioning strategy API for menus that change in size after mounting.

---

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.