callstack / callstack/react-native-paper

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

Open
#4,747 0 comments 1 reaction 0 assignees View on GitHub
feature request
Dominant language
TypeScript
Stars
14.5k
Forks
2.2k
Avg merge
5d 23h
Merged PRs (30d)
12

Description

## 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.

---

Contributor guide

Open the contributing guide

Research direction

No file or test is named. Start by locating the Menu component's positioning logic and examine how upward-opening menus respond to dynamic content changes. Done means the menu remains visually aligned with its anchor as its filtered content changes, with the positioning behavior covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
frontend, mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.