Skip to content

Commit a8482f8

Browse files
committed
feat(lib): close the fab menu when item is selected
1 parent 2220504 commit a8482f8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

projects/angular-material-extensions/fab-menu/src/lib/mat-fab-menu.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</div>
1313
<div *ngIf="isActive" [@fabsStagger]="fabButtons.length"
1414
[fxLayout]="layout2" fxLayoutAlign="center center" fxLayoutGap="16px">
15-
<button (click)="onFabMenuItemSelected.emit(fab.id)"
15+
<button (click)="selectFabMenu(fab); onFabMenuItemSelected.emit(fab.id)"
1616
*ngFor="let fab of fabButtons"
1717
[color]="fab?.color"
1818
[matTooltip]="fab?.tooltip"

projects/angular-material-extensions/fab-menu/src/lib/mat-fab-menu.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export class MatFabMenuComponent implements OnInit, OnChanges {
4040
@Input()
4141
disabled: boolean;
4242

43+
@Input()
44+
closeAfterSelection = true;
45+
4346
// tslint:disable-next-line:no-output-on-prefix
4447
@Output()
4548
onFabMenuItemSelected: EventEmitter<string | number> = new EventEmitter<string | number>();
@@ -96,4 +99,11 @@ export class MatFabMenuComponent implements OnInit, OnChanges {
9699
toggle() {
97100
this.isActive = !this.isActive;
98101
}
102+
103+
selectFabMenu(fab: MatFabMenu) {
104+
this.onFabMenuItemSelected.emit(fab.id);
105+
if (this.closeAfterSelection) {
106+
this.isActive = false;
107+
}
108+
}
99109
}

0 commit comments

Comments
 (0)