don't allow empty constructs of node context
This commit is contained in:
@@ -59,7 +59,7 @@ export class UmbEditorNodeElement extends UmbContextProviderMixin(UmbContextCons
|
||||
private _nodeStore?: UmbNodeStore;
|
||||
private _nodeStoreSubscription?: Subscription;
|
||||
|
||||
private _nodeContext = new UmbNodeContext();
|
||||
private _nodeContext?: UmbNodeContext;
|
||||
private _nodeContextSubscription?: Subscription;
|
||||
|
||||
private _notificationService?: UmbNotificationService;
|
||||
@@ -77,8 +77,6 @@ export class UmbEditorNodeElement extends UmbContextProviderMixin(UmbContextCons
|
||||
});
|
||||
|
||||
this.addEventListener('property-value-change', this._onPropertyValueChange);
|
||||
|
||||
this.provideContext('umbNodeContext', this._nodeContext);
|
||||
}
|
||||
|
||||
private _onPropertyValueChange = (e: Event) => {
|
||||
@@ -109,7 +107,12 @@ export class UmbEditorNodeElement extends UmbContextProviderMixin(UmbContextCons
|
||||
|
||||
this._nodeContextSubscription?.unsubscribe();
|
||||
|
||||
this._nodeContext?.update(node);
|
||||
if (!this._nodeContext) {
|
||||
this._nodeContext = new UmbNodeContext(node);
|
||||
this.provideContext('umbNodeContext', this._nodeContext);
|
||||
} else {
|
||||
this._nodeContext.update(node);
|
||||
}
|
||||
|
||||
this._nodeContextSubscription = this._nodeContext.data.pipe(distinctUntilChanged()).subscribe((data) => {
|
||||
this._node = data;
|
||||
|
||||
@@ -26,7 +26,7 @@ export class UmbNodeContext {
|
||||
});
|
||||
public readonly data: Observable<NodeEntity> = this._data.asObservable();
|
||||
|
||||
constructor(node?: NodeEntity) {
|
||||
constructor(node: NodeEntity) {
|
||||
if (!node) return;
|
||||
this._data.next(node);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user