From af82e757a749234d57a09583aa3ef116d4709ada Mon Sep 17 00:00:00 2001 From: Tanishq Gandhi Date: Wed, 2 Sep 2026 11:52:02 -0700 Subject: [PATCH] fix(frontend): remove the clear button from the dataset version picker The version dropdown on a dataset's detail page carried nzAllowClear, so clicking the x emitted null into onVersionSelected(version: DatasetVersion), which read this.selectedVersion.dvid and threw an uncaught TypeError. The page was left half-cleared: the main pane said "No version is selected" while the header still showed the cleared version's file path and the file tree still listed its files. Clearing the selection means nothing on a page whose entire content is one version, so the button goes away. onVersionSelected also takes an optional version now and skips the fetch without a dvid, so an empty selection cannot throw even if the control pushes one. This mirrors the model detail page. Closes #8342. --- .../dataset-detail.component.html | 1 - .../dataset-detail.component.spec.ts | 15 +++++++++++++++ .../dataset-detail.component.ts | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html index 777a1537654..5263213bbb1 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html @@ -395,7 +395,6 @@
Choose a Version:
diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts index b91db9c8fe4..617ae665590 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts @@ -704,6 +704,16 @@ describe("DatasetDetailComponent behavior", () => { expect(component.selectedVersionCreationTime).toMatch(/^\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2}$/); }); + it("survives the version select being emptied", () => { + createComponent(); + component.did = 5; + + expect(() => component.onVersionSelected(undefined)).not.toThrow(); + + expect(component.selectedVersion).toBeUndefined(); + expect(datasetServiceStub.retrieveDatasetVersionFileTree).not.toHaveBeenCalled(); + }); + it("does not fetch a file tree for a version without a dvid", () => { createComponent(); component.did = 5; @@ -2422,6 +2432,11 @@ describe("DatasetDetailComponent rendered template", () => { expect(datasetService.retrieveDatasetVersionFileTree).toHaveBeenCalledWith(5, 13, true); }); + it("offers no way to empty the selection", () => { + // Clearing it used to reach onVersionSelected as null and throw. + expect(fixture.nativeElement.querySelector("nz-select-clear, .ant-select-clear")).toBeNull(); + }); + it("loads a picked version over the anonymous endpoint when nobody is signed in", () => { render({ isLogin: false }); diff --git a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts index 535156b9541..72f89eb57b7 100644 --- a/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts +++ b/frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts @@ -424,11 +424,11 @@ export class DatasetDetailComponent implements OnInit { this.isRightBarCollapsed = !this.isRightBarCollapsed; } - onVersionSelected(version: DatasetVersion): void { + onVersionSelected(version: DatasetVersion | undefined): void { this.selectedVersion = version; - if (this.did && this.selectedVersion.dvid) + if (this.did && version?.dvid) this.datasetService - .retrieveDatasetVersionFileTree(this.did, this.selectedVersion.dvid, this.isLogin) + .retrieveDatasetVersionFileTree(this.did, version.dvid, this.isLogin) .pipe(untilDestroyed(this)) .subscribe(data => { this.fileTreeNodeList = data.fileNodes;