Skip to content

Commit

Permalink
Fixed another NG100
Browse files Browse the repository at this point in the history
Since canEditProject was being updated in the event handler, as well, we were seeing NG100 in cases where the user lacked permissions. This seems to stem from the project select output event, which we're using to update further views.

This behavior seems quite normal/expected when using the component, so it might be due to a deficiency in the project select component itself. But I need to investigate this more. It may be related to SF-3014.
  • Loading branch information
josephmyers committed Jan 27, 2025
1 parent 47ebbab commit 1ac2c36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h2 mat-dialog-title>{{ t("select_alternate_project") }}</h2>
@if (!isAppOnline) {
<mat-error class="offline-message">{{ t("connect_to_the_internet") }}</mat-error>
}
@if (projectSelectValid && canEditProject) {
@if (isValid) {
<div class="target-project-content">
@if (targetChapters$ | async; as chapters) {
<app-notice icon="warning" type="warning"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class DraftApplyDialogComponent implements OnInit {
// the project id to add the draft to
private targetProjectId?: string;
private paratextIdToProjectId: Map<string, string> = new Map<string, string>();
isValid: boolean = false;

constructor(
@Inject(MAT_DIALOG_DATA) private data: DraftApplyDialogConfig,
Expand Down Expand Up @@ -188,8 +189,11 @@ export class DraftApplyDialogComponent implements OnInit {
}

private validateProject(): void {
// setTimeout prevents a "changed after checked" exception
setTimeout(() => this.projectSelect?.customValidate(SFValidators.customValidator(this.getCustomErrorState())));
// setTimeout prevents a "changed after checked" exception (may be removable after SF-3014)
setTimeout(() => {
this.isValid = this.getCustomErrorState() === CustomErrorState.None;
this.projectSelect?.customValidate(SFValidators.customValidator(this.getCustomErrorState()));
});
}

private async chaptersWithTextAsync(project: SFProjectProfile): Promise<number> {
Expand Down

0 comments on commit 1ac2c36

Please sign in to comment.