From 6813542f29ca6d536c7dc08977ab6aaf11de2d08 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 12 Feb 2026 11:05:10 -0800 Subject: [PATCH] Fix UI content should change on version select and thumbnail --- .../document-detail.component.spec.ts | 4 +++ .../document-detail.component.ts | 32 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts index 39c55e8da..ca6f48d1b 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts @@ -1616,6 +1616,9 @@ describe('DocumentDetailComponent', () => { previewSpy.mockReturnValueOnce('preview-version') jest.spyOn(documentService, 'getThumbUrl').mockReturnValue('thumb-version') + jest + .spyOn(documentService, 'get') + .mockReturnValue(of({ content: 'version-content' } as Document)) component.selectVersion(10) httpTestingController.expectOne('preview-version').flush('version text') @@ -1623,6 +1626,7 @@ describe('DocumentDetailComponent', () => { expect(component.previewUrl).toBe('preview-version') expect(component.thumbUrl).toBe('thumb-version') expect(component.previewText).toBe('version text') + expect(component.documentForm.get('content').value).toBe('version-content') const pdfSource = component.pdfSource as { url: string; password?: string } expect(pdfSource.url).toBe('preview-version') expect(pdfSource.password).toBeUndefined() diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 06ae6a6c5..eaab781c6 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -805,8 +805,38 @@ export class DocumentDetailComponent this.selectedVersionId ) this.updatePdfSource() - this.thumbUrl = this.documentsService.getThumbUrl(this.selectedVersionId) + this.thumbUrl = this.documentsService.getThumbUrl( + this.documentId, + this.selectedVersionId + ) this.loadMetadataForSelectedVersion() + this.documentsService + .get(this.documentId, this.selectedVersionId, 'content') + .pipe( + first(), + takeUntil(this.unsubscribeNotifier), + takeUntil(this.docChangeNotifier) + ) + .subscribe({ + next: (doc) => { + const content = doc?.content ?? '' + this.document.content = content + this.documentForm.patchValue( + { + content, + }, + { + emitEvent: false, + } + ) + }, + error: (error) => { + this.toastService.showError( + $localize`Error retrieving version content`, + error + ) + }, + }) // For text previews, refresh content this.http .get(this.previewUrl, { responseType: 'text' })