Skip to content

feat(cdk-experimental/menu): allow configuration of typeahead and menu position #24600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 22, 2022

Conversation

mmalerba
Copy link
Contributor

Addresses several TODOs that were left after the original implementation

…u position

Addresses several TODOs that were left after the original implementation
@mmalerba mmalerba requested a review from crisbeto March 15, 2022 18:22
@mmalerba mmalerba requested a review from jelbourn as a code owner March 15, 2022 18:22
@@ -287,7 +287,6 @@ export class CdkMenuItemTrigger extends MenuTrigger implements OnDestroy {

/** Determine and return where to position the opened menu relative to the menu item */
private _getOverlayPositions(): ConnectedPosition[] {
// TODO: use a common positioning config from (possibly) cdk/overlay
Copy link
Contributor Author

@mmalerba mmalerba Mar 15, 2022

Choose a reason for hiding this comment

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

I couldn't really think of a way to create common configs that seemed useful. The only idea I really had is maybe we can create a function that takes your top preferred position and generates some mirrored fallbacks automatically. e.g.

getPositionWithFallbacks(
	{originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top'}
) === [
	{originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top'},
	{originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom'},
	{originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top'},
	{originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom'},
]

Do you think this is worth it? Do you have other ideas?

Copy link
Member

Choose a reason for hiding this comment

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

I had been imaging this as something roughly like

const STANDARD_DROPDOWN_POSITIONS = [
  {originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top'},
  ...
];

const STANDARD_PICKER_POSITIONS = [...];

where the first would be the behavior that we use as the default for things with a list of items (menu, select, autocomplete), and picker would be for things like datepicker, color picker, that typically have more custom UI. The difference being the flexibility setting for the most part

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the problem with this is that there's not really a single standard set of positions. For horizontal menu bars and single button triggers the standard is to open the menu below the trigger. For sidebar menus and sub-menus the standard is to open the menu adjacent to the end of the trigger. We could save those both as different presets if we can come up with good names for them, but I'm having trouble coming up with good names that aren't a mouthful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just went with STANDARD_DROPDOWN_BELOW_POSITIONS and STANDARD_DROPDOWN_ADJACENT_POSITIONS. LMK if you have better suggestions

@mmalerba mmalerba requested a review from a team as a code owner March 17, 2022 22:18
@mmalerba mmalerba added the target: major This PR is targeted for the next major release label Mar 18, 2022
@mmalerba
Copy link
Contributor Author

PTAL, ready for re-review

@josephperrott josephperrott removed the request for review from a team March 21, 2022 14:56
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Mar 21, 2022
@wagnermaciel wagnermaciel merged commit 4cc6b04 into angular:master Mar 22, 2022
forsti0506 pushed a commit to forsti0506/components that referenced this pull request Apr 3, 2022
…u position (angular#24600)

* feat(cdk-experimental/menu): allow configuration of typeahead and menu position

Addresses several TODOs that were left after the original implementation

* fixup! feat(cdk-experimental/menu): allow configuration of typeahead and menu position

* fixup! feat(cdk-experimental/menu): allow configuration of typeahead and menu position
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants