Skip to content

Commit c66e6a2

Browse files
kz930claude
andcommitted
fix(frontend): stop the spinner when a column search leaves an empty result with no columns
A 0-row result now always shows its schema's columns, even none, so a search that matches nothing clears the old headers. Every page that arrives ends the loading state, including an empty page past the end of a non-empty result. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a2a1686 commit c66e6a2

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

‎frontend/src/app/workspace/component/result-panel/result-table-frame/result-table-frame.component.spec.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,22 @@ describe("ResultTableFrameComponent", () => {
285285
expect(component.currentColumns?.map(c => c.header)).toEqual(["name", "score"]);
286286
});
287287

288+
it("drops the old headers and stops loading when a search matches no column of an empty result", () => {
289+
component.operatorId = "op1";
290+
component.setupResultTable([], 0, [{ attributeName: "name", attributeType: "string" }]);
291+
makePaginatedResultService({
292+
getCurrentTotalNumTuples: vi.fn().mockReturnValue(0),
293+
selectPage: vi.fn().mockReturnValue(of(makePageEvent(component.currentPageIndex, []))),
294+
});
295+
296+
const input: HTMLInputElement = fixture.nativeElement.querySelector("input[nz-input]");
297+
input.value = "missing";
298+
input.dispatchEvent(new Event("input"));
299+
300+
expect(component.isLoadingResult).toBe(false);
301+
expect(component.currentColumns).toEqual([]);
302+
});
303+
288304
it("builds columns from the first row and drops the internal _id column", () => {
289305
component.operatorId = "op1";
290306
component.isLoadingResult = true;

‎frontend/src/app/workspace/component/result-panel/result-table-frame/result-table-frame.component.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,16 +427,18 @@ export class ResultTableFrameComponent implements OnInit, OnChanges {
427427
if (!this.operatorId) {
428428
return;
429429
}
430+
// Every page that arrives ends the fetch, including one that changes nothing below.
431+
this.isLoadingResult = false;
432+
this.changeDetectorRef.detectChanges();
433+
430434
// A result with no rows still has columns, and showing them tells the user what the
431-
// operator would have produced. An empty page of a non-empty result is only a page index
432-
// past the end, so the table already shown stays.
433-
if (resultData.length < 1 && (totalRowCount > 0 || schema.length === 0)) {
435+
// operator would have produced. A column search can leave none, and the old headers must
436+
// not stay. An empty page of a non-empty result is only a page index past the end, so the
437+
// table already shown stays.
438+
if (resultData.length < 1 && totalRowCount > 0) {
434439
return;
435440
}
436441

437-
this.isLoadingResult = false;
438-
this.changeDetectorRef.detectChanges();
439-
440442
// creates a shallow copy of the readonly response.result,
441443
// this copy will be has type object[] because MatTableDataSource's input needs to be object[]
442444
this.currentResult = resultData.slice();

0 commit comments

Comments
 (0)