-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
feat(expansion): emit animation events for expansion panels #12412
Conversation
src/lib/expansion/expansion-panel.ts
Outdated
@@ -78,6 +80,18 @@ export class MatExpansionPanel extends CdkAccordionItem | |||
} | |||
private _hideToggle = false; | |||
|
|||
/** An event emitted before the body's expansion animation happens. */ | |||
@Output() beforeExpanded = new EventEmitter<null>(); |
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.
I'm not sure whether emitting null
is particularly useful. We should either switch it to void
or emit the AnimationEvent
.
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.
I definitely meant void
and then typed null
src/lib/expansion/expansion-panel.ts
Outdated
if (fromState !== 'void') { | ||
this.afterExpanded.emit(); | ||
} | ||
return; |
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.
I'm not sure whether all of these returns are necessary. If the state is something different, it just won't go into the other conditions. Also can we break this up a bit since it's a fair bit of if
-s in one place?
src/lib/expansion/expansion.spec.ts
Outdated
const afterExpanded = fixture.componentInstance.panel.afterExpanded; | ||
const beforeCollapsed = fixture.componentInstance.panel.beforeCollapsed; | ||
const afterCollapsed = fixture.componentInstance.panel.afterCollapsed; | ||
spyOn(beforeExpanded, '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.
We should subscribe to the EventEmitter
, rather than stubbing out its emit
method.
@@ -1,6 +1,10 @@ | |||
<h1>Single Expansion Panel</h1> | |||
|
|||
<mat-expansion-panel class="demo-expansion-width" #myPanel> | |||
<mat-expansion-panel class="demo-expansion-width" #myPanel | |||
(beforeExpanded)="addEvent('beforeExpanded')" |
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.
Indent +4?
src/lib/expansion/expansion-panel.ts
Outdated
_changeDetectorRef: ChangeDetectorRef, | ||
_uniqueSelectionDispatcher: UniqueSelectionDispatcher, | ||
private _viewContainerRef: ViewContainerRef) { | ||
_changeDetectorRef: ChangeDetectorRef, |
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.
Indent should be +4
src/lib/expansion/expansion-panel.ts
Outdated
@Output() beforeCollapsed = new EventEmitter<null>(); | ||
|
||
/** An event emitted after the body's collapse animation happens. */ | ||
@Output() afterCollapsed = new EventEmitter<null>(); |
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.
Any thoughts on e.g. afterExpand
vs. afterExpanded
?
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.
Updated to match the other usages in the library
98a8cf1
to
699283f
Compare
699283f
to
05ae185
Compare
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
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. |
Fixes #11838