Skip to content

fix(menu): make @Output names consistent #6677 #7133

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

Closed
wants to merge 7 commits into from

Conversation

amcdnl
Copy link
Contributor

@amcdnl amcdnl commented Sep 17, 2017

Updates the Menu API with the following API modifications per #6677

  • close to closed
  • hover to hovered
  • onMenuOpen to menuOpened
  • onMenuClose to menuClosed

@amcdnl amcdnl self-assigned this Sep 17, 2017
@amcdnl amcdnl requested a review from jelbourn September 17, 2017 17:53
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 17, 2017
@amcdnl amcdnl removed request for kara and crisbeto September 17, 2017 17:53
this._menuOpen ? this.onMenuOpen.emit() : this.onMenuClose.emit();

if (this._menuOpen) {
this.onMenuOpen.emit();
Copy link
Member

Choose a reason for hiding this comment

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

Rather than having to emit to multiple subjects, why not have something like:

@Output() onMenuOpen = new EventEmitter<void>();
@Output() onMenuOpened = this.onMenuOpen;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! Done :)

* Event emitted when the menu is closed.
* @deprecated Switch to `closed` instead
*/
@Output() close = this.closed;
Copy link
Member

Choose a reason for hiding this comment

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

Same question here as the select- should we just have one openedChange?
cc @kara @crisbeto

Copy link
Member

Choose a reason for hiding this comment

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

That's fine by me, just need to mark it as a breaking change or deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jelbourn - Ok, to verify we want to changeopen and close to openChange with a signature like:

export interface MdMenuEvent {
   opened: boolean;
   type: void | 'click' | 'keydown'
}

if (this.menu.close) {
this.menu.close.emit();
}
this.menu.closed.emit();
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this any more?

this.menu.close.emit();
if (this.menu.close) {
this.menu.close.emit();
}
Copy link
Member

Choose a reason for hiding this comment

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

And this?

@@ -203,7 +216,12 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
openMenu(): void {
if (!this._menuOpen) {
this._createOverlay().attach(this._portal);
this._closeSubscription = this._menuClosingActions().subscribe(() => this.menu.close.emit());
this._closeSubscription = this._menuClosingActions().subscribe(() => {
if (this.menu.close) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this null check? The close emitter should always be there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the interface MdMenuPanel it declared a close EventEmitter. As part of this deprecation, I made that an optional interface and made closed the new interface. The implementation of this required I add a null check in those spots. If we are ok with removing that from the interface, we can remove all of this.

@@ -218,7 +236,11 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
this._resetMenu();
this._overlayRef.detach();
this._closeSubscription.unsubscribe();
this.menu.close.emit();
if (this.menu.close) {
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't need this null check either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above comment.

@jelbourn jelbourn added the P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful label Sep 22, 2017
this._tabSubscription = this._keyManager.tabOut.subscribe(() => this.close.emit('keydown'));
this._tabSubscription = this._keyManager.tabOut.subscribe(() => {
this.close.emit('keydown');
this.closed.emit('keydown');
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't emit to both of these anymore. Since they're pointing to the same emitter, you'll end up emitting the same event twice.

@amcdnl
Copy link
Contributor Author

amcdnl commented Sep 24, 2017

Updated minus the new api question above.

@jelbourn
Copy link
Member

Also just noticed- @kara @crisbeto why is there a hover event? Is that meant to be internal only? I would think downstream users would use mouseover etc. like normal

@crisbeto
Copy link
Member

The hover event is internal, I added it to accommodate the nested menus.

@jelbourn
Copy link
Member

Ack, @amcdnl can you change hover to just be internal?

@amcdnl
Copy link
Contributor Author

amcdnl commented Sep 30, 2017

@jelbourn - done.

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 pr: lgtm action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Oct 24, 2017
@jelbourn
Copy link
Member

Caretaker note: should be completely backwards compatible, so if something fails there's a bug

@amcdnl amcdnl changed the title chore(api): update menu api per #6677 fix(menu): make @Output names consistent #6677 Oct 25, 2017
@amcdnl
Copy link
Contributor Author

amcdnl commented Oct 26, 2017

Closing of favor of #8053

@amcdnl amcdnl closed this Oct 26, 2017
@amcdnl amcdnl deleted the menu-outputs-6677 branch October 26, 2017 19:14
@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 7, 2019
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 merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants