Skip to content

feat(cdk-experimental/menu): add support for inline menus #20143

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 1 commit into from
Aug 5, 2020

Conversation

andy9775
Copy link
Contributor

Add the ability to place a menu inline (always visible and not trigered) which is typically used as
a navigation menu.

@andy9775 andy9775 requested a review from jelbourn as a code owner July 30, 2020 14:45
@andy9775 andy9775 requested a review from teflonwaffles July 30, 2020 14:45
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 30, 2020
@@ -126,3 +126,19 @@ export class MenuStack {
return this._elements[this._elements.length - 1];
}
}

/** NoopMenuStack is a placeholder MenuStack used for inline menus. */

Choose a reason for hiding this comment

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

Just to clarify -- does 'inline' mean it's triggered by some means other than a bar? (Such as a button?) I'd make this clearer in the documentation somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Inline menus aren't triggered open at all - they're always open. Think of the list of mailboxes on gmail (inbox, starred, snoozed, ...).

@@ -126,3 +126,19 @@ export class MenuStack {
return this._elements[this._elements.length - 1];
}
}

/** NoopMenuStack is a placeholder MenuStack used for inline menus. */
export class NoopMenuStack extends MenuStack {
Copy link
Member

Choose a reason for hiding this comment

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

TypeScript lets you do implements MenuStack so you can conform to the same API without actually inheriting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems to work only if all members are public. With private and protected it won't allow it.

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines 133 to 134
closeInclusive(lastItem: MenuStackItem, focusNext?: FocusNext) {}
closeExclusive(lastItem: MenuStackItem) {}
Copy link
Member

Choose a reason for hiding this comment

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

I think these are the old method names

Comment on lines 75 to 76
/** Track the Menus making up the open menu stack. */
_menuStack: MenuStack;
// We provide a default MenuStack implementation in case the menu is an inline menu.
// For Menus part of a MenuBar nested within a MenuPanel this will be overwritten
// to the correct parent MenuStack.
Copy link
Member

Choose a reason for hiding this comment

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

Adding implementation comments between a JsDoc and a member will break the connection

Comment on lines 333 to 334
* Return true if this menu is an inline menu. That is, it exists in isolation apart from a menu
* bar.
Copy link
Member

Choose a reason for hiding this comment

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

My understanding is that it's more that an inline menu doesn't exist in a pop-up rather than being strictly related to a menubar.

@@ -52,6 +51,8 @@ import {getItemPointerEntries} from './item-pointer-entries';
exportAs: 'cdkMenu',
host: {
'(keydown)': '_handleKeyEvent($event)',
'(focus)': '_focusFirstItem()',
'[tabindex]': '_getTabIndex()',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'[tabindex]': '_getTabIndex()',
'[tabindex]': '_isInline() ? 0 : null',

It would be acceptable to inline the expression here without creating a new method


/** Set focus to the first menu item if this is an inline menu. */
_focusFirstItem() {
if (this._isInline()) {
Copy link
Member

Choose a reason for hiding this comment

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

Since focus doesn't bubble, you could just always call this._keyManager.setFirstItemActive(); without checking if the menu is line since this menu element will only even be focusable when it's inline

@andy9775 andy9775 force-pushed the cdk-menu-inline-menu branch 5 times, most recently from 4a69426 to 891dcb4 Compare August 1, 2020 00:04
@jelbourn jelbourn added the target: minor This PR is targeted for the next minor release label Aug 3, 2020
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker merge safe labels Aug 3, 2020
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

Add the ability to place a menu inline (always visible and not trigered) which is typically used as
a navigation menu.
@andy9775 andy9775 force-pushed the cdk-menu-inline-menu branch from 891dcb4 to 9fcb2fb Compare August 5, 2020 20:02
@mmalerba mmalerba merged commit 8b68083 into angular:master Aug 5, 2020
@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 Sep 5, 2020
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 cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants