Skip to content

Commit

Permalink
Add manual trigger of changeDetector in Master Renderer
Browse files Browse the repository at this point in the history
When the data array of the list master detail renderer is empty,
then changing the data does not rerender the ui.
To fix this the changeDetector is manually triggered.
This error can only be reproduced in the seed,
not from the dev environment.
Furthermore the readonly handling was fixed.

Fix #1667
  • Loading branch information
eneufeld committed Dec 23, 2020
1 parent bbe2fab commit 52e11f6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/angular-material/src/other/master-detail/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
import some from 'lodash/some';
import get from 'lodash/get';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component } from '@angular/core';
import {
JsonFormsAngularService,
JsonFormsArrayControl
Expand All @@ -39,7 +39,6 @@ import {
mapStateToArrayControlProps,
RankedTester,
rankWith,
setReadonly,
StatePropsOfArrayControl,
uiTypeIs
} from '@jsonforms/core';
Expand Down Expand Up @@ -146,7 +145,7 @@ export class MasterListComponent extends JsonFormsArrayControl {
propsPath: string;
highlightedIdx: number;

constructor(jsonformsService: JsonFormsAngularService) {
constructor(jsonformsService: JsonFormsAngularService, private changeDetectorRef: ChangeDetectorRef) {
super(jsonformsService);
}

Expand Down Expand Up @@ -179,9 +178,6 @@ export class MasterListComponent extends JsonFormsArrayControl {
props.path,
'VerticalLayout'
);
if (!this.isEnabled()) {
setReadonly(detailUISchema);
}

const masterItems = (data || []).map((d: any, index: number) => {
const labelRefInstancePath = removeSchemaKeywords(
Expand Down Expand Up @@ -229,6 +225,7 @@ export class MasterListComponent extends JsonFormsArrayControl {
this.selectedItem = this.masterItems[0];
this.selectedItemIdx = 0;
}
this.changeDetectorRef.markForCheck();
}

onSelect(item: any, idx: number): void {
Expand Down

0 comments on commit 52e11f6

Please sign in to comment.