Skip to content

Commit

Permalink
fix(lib): fix viewHandler on grouped elements
Browse files Browse the repository at this point in the history
  • Loading branch information
geromegrignon committed Jan 24, 2021
1 parent 622afaf commit 7eaffe3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class EditableGroupDirective implements AfterViewInit {
@Output() editableModeChange: EventEmitter<Mode> = new EventEmitter<Mode>();

ngAfterViewInit(): void {
this.children.forEach((child) => (child.isGrouped = true));
this.children.forEach((child) => child.viewHandler.unsubscribe());
this.children.forEach((child) => child.editHandler.unsubscribe());
}
Expand Down
7 changes: 5 additions & 2 deletions projects/ngneat/edit-in-place/src/lib/editable.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class EditableComponent implements OnInit, OnDestroy {
public viewHandler: Subscription;
public editHandler: Subscription;
private destroy$: Subject<boolean> = new Subject<boolean>();
public isGrouped = false;

constructor(private readonly el: ElementRef, @Inject(EDITABLE_CONFIG) readonly config: EditableConfig) {}

Expand Down Expand Up @@ -106,7 +107,9 @@ export class EditableComponent implements OnInit, OnDestroy {
private leaveEditMode(): void {
this.editMode.next(false);
this.modeChange.emit('view');
this.viewHandler.unsubscribe();
setTimeout(() => this.handleViewMode(), 0);
if (!this.isGrouped) {
this.viewHandler.unsubscribe();
setTimeout(() => this.handleViewMode(), 0);
}
}
}

0 comments on commit 7eaffe3

Please sign in to comment.