From 0bbe180f63f9d85522adbe198d26cbb50ae65787 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Sat, 1 Aug 2026 13:27:34 -0700
Subject: [PATCH] Fix: fix edit dialog error change detection (#13483)
---
.../edit-dialog/edit-dialog.component.spec.ts | 20 +++++++++++++++++++
.../edit-dialog/edit-dialog.component.ts | 5 +++++
2 files changed, 25 insertions(+)
diff --git a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts
index 6dd1e11c9..5eaa9537b 100644
--- a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts
+++ b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts
@@ -32,6 +32,8 @@ import { EditDialogComponent, EditDialogMode } from './edit-dialog.component'
template: `
{{ getTitle() }}
+ {{ error?.name }}
+
`,
imports: [FormsModule, ReactiveFormsModule],
@@ -276,4 +278,22 @@ describe('EditDialogComponent', () => {
expect(failedSpy).toHaveBeenCalled()
expect(component.error).toEqual('error')
})
+
+ it('should update the view after a failed save', async () => {
+ const button: HTMLButtonElement =
+ fixture.nativeElement.querySelector('button')
+ button.click()
+ await fixture.whenStable()
+ expect(button.disabled).toBe(true)
+
+ httpTestingController
+ .expectOne(`${environment.apiBaseUrl}tags/`)
+ .flush({ name: ['Name is required.'] }, { status: 400, statusText: '' })
+ await fixture.whenStable()
+
+ expect(button.disabled).toBe(false)
+ expect(fixture.nativeElement.querySelector('.error').textContent).toContain(
+ 'Name is required.'
+ )
+ })
})
diff --git a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts
index 456ba69f9..d9fc611d6 100644
--- a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts
+++ b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts
@@ -1,4 +1,5 @@
import {
+ ChangeDetectorRef,
Directive,
EventEmitter,
Input,
@@ -45,6 +46,7 @@ export abstract class EditDialogComponent<
protected userService = inject(UserService)
protected settingsService = inject(SettingsService)
protected permissionsService = inject(PermissionsService)
+ protected changeDetector = inject(ChangeDetectorRef)
dialogMode = model(EditDialogMode.CREATE)
@@ -108,10 +110,12 @@ export abstract class EditDialogComponent<
// wait to enable close button so it doesn't steal focus from input since its the first clickable element in the DOM
setTimeout(() => {
this.closeEnabled = true
+ this.changeDetector.markForCheck()
})
this.userService.listAll().subscribe((r) => {
this.users = r.results
+ this.changeDetector.markForCheck()
})
}
@@ -191,6 +195,7 @@ export abstract class EditDialogComponent<
this.error = error.error
this.networkActive = false
this.failed.next(error)
+ this.changeDetector.markForCheck()
},
})
}