Skip to content
Snippets Groups Projects
Commit 3d305862 authored by rhenck's avatar rhenck
Browse files

[editor] Select newly created element

parent 3892a19c
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ import { ...@@ -2,7 +2,7 @@ import {
Directive, Input, Directive, Input,
ComponentFactoryResolver, ComponentRef, ComponentFactoryResolver, ComponentRef,
HostListener, HostListener,
ViewChild, ViewContainerRef, OnInit, AfterViewInit, OnDestroy ViewChild, ViewContainerRef, OnInit, OnDestroy
} from '@angular/core'; } from '@angular/core';
import { forkJoin, Subject } from 'rxjs'; import { forkJoin, Subject } from 'rxjs';
import { take, takeUntil } from 'rxjs/operators'; import { take, takeUntil } from 'rxjs/operators';
...@@ -25,13 +25,19 @@ export abstract class CanvasElementOverlay implements OnInit, OnDestroy { ...@@ -25,13 +25,19 @@ export abstract class CanvasElementOverlay implements OnInit, OnDestroy {
constructor(public selectionService: SelectionService, constructor(public selectionService: SelectionService,
protected unitService: UnitService, protected unitService: UnitService,
private componentFactoryResolver: ComponentFactoryResolver) { } private componentFactoryResolver: ComponentFactoryResolver) {
// Needs to be run before change detection to set 'selected' and avoid
// NG0100: Expression has changed after it was checked
this.selectionService.selectElement({ componentElement: this, multiSelect: false });
}
ngOnInit(): void { ngOnInit(): void {
const componentFactory = ComponentUtils.getComponentFactory(this.element.type, this.componentFactoryResolver); const componentFactory = ComponentUtils.getComponentFactory(this.element.type, this.componentFactoryResolver);
this.childComponent = this.elementContainer.createComponent(componentFactory); this.childComponent = this.elementContainer.createComponent(componentFactory);
this.childComponent.instance.elementModel = this.element; this.childComponent.instance.elementModel = this.element;
this.selectionService.selectElement({ componentElement: this, multiSelect: false });
if (this.childComponent.instance instanceof FormElementComponent) { if (this.childComponent.instance instanceof FormElementComponent) {
this.childComponent.instance.formValueChanged this.childComponent.instance.formValueChanged
.pipe(takeUntil(this.ngUnsubscribe)) .pipe(takeUntil(this.ngUnsubscribe))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment