-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Conversation
src/lib/menu/menu-trigger.ts
Outdated
this._menuOpen ? this.onMenuOpen.emit() : this.onMenuClose.emit(); | ||
|
||
if (this._menuOpen) { | ||
this.onMenuOpen.emit(); |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'
}
src/lib/menu/menu-trigger.ts
Outdated
if (this.menu.close) { | ||
this.menu.close.emit(); | ||
} | ||
this.menu.closed.emit(); |
There was a problem hiding this comment.
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?
src/lib/menu/menu-trigger.ts
Outdated
this.menu.close.emit(); | ||
if (this.menu.close) { | ||
this.menu.close.emit(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this?
src/lib/menu/menu-trigger.ts
Outdated
@@ -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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/lib/menu/menu-trigger.ts
Outdated
@@ -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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comment.
src/lib/menu/menu-directive.ts
Outdated
this._tabSubscription = this._keyManager.tabOut.subscribe(() => this.close.emit('keydown')); | ||
this._tabSubscription = this._keyManager.tabOut.subscribe(() => { | ||
this.close.emit('keydown'); | ||
this.closed.emit('keydown'); |
There was a problem hiding this comment.
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.
Updated minus the new api question above. |
The hover event is internal, I added it to accommodate the nested menus. |
Ack, @amcdnl can you change |
@jelbourn - done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Caretaker note: should be completely backwards compatible, so if something fails there's a bug |
Closing of favor of #8053 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Updates the Menu API with the following API modifications per #6677
close
toclosed
hover
tohovered
onMenuOpen
tomenuOpened
onMenuClose
tomenuClosed