Skip to content

feat(components): Add Placement Prop to Menu#3024

Open
ZakaryH wants to merge 4 commits intomasterfrom
menu-position-prop-please
Open

feat(components): Add Placement Prop to Menu#3024
ZakaryH wants to merge 4 commits intomasterfrom
menu-position-prop-please

Conversation

@ZakaryH
Copy link
Copy Markdown
Contributor

@ZakaryH ZakaryH commented Mar 30, 2026

Motivations

Menu uses a "floating" popup to show the items, since we have a Trigger that we anchor to - it's reasonable to want to decide which side it should go on, when it can.

note that the "flipping" behavior when we can't do what the preferred placement wants is already enabled by the default on AriaPopover

image

we will default to "bottom start" to avoid being too great of a change, and that's a reasonable default imo.

Changes

Added

new prop preferredPlacement (matches Popover) on Menu.Content to set the preferred position of the Menu popup.

Changed

Deprecated

Removed

Fixed

Security

Testing

try using the new prop on a composable Menu, it should respect the value when it can. note that this behavior comes entirely from RAC, so there's not much for us to test.

Changes can be
tested via Pre-release


In Atlantis we use Github's built in pull request reviews.

ReactNode,
} from "react";
import type { Pressable as AriaPressable } from "react-aria-components";
import type { Placement } from "@react-types/overlays";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only thing I'm a little unsure about. this is using RAC's Placement and values

on Popover we offer
readonly preferredPlacement?: "top" | "bottom" | "left" | "right" | "auto";

but this will be

Image

so we're not being consistent, but the granularity is so much greater. it's perfectly reasonable to want to be bottom start or bottom end. bottom alone can't capture that.

so there's a small decision to make here around what naming convention we wanna use. hyphenated is another one I've seen e.g bottom-end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can come up with our own Placement type to re-use across the project when dealing with this sort of prop.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 30, 2026

Deploying atlantis with  Cloudflare Pages  Cloudflare Pages

Latest commit: aa8c5f4
Status: ✅  Deploy successful!
Preview URL: https://b119c5b5.atlantis.pages.dev
Branch Preview URL: https://menu-position-prop-please.atlantis.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant