Skip to content

Commit cc89493

Browse files
authored
Fix issue 53192 (#1803)
- QueryModel: add isQueryInfoLoaded - withQueryModels: be more defensive when loading rows and total count
1 parent 99660fc commit cc89493

6 files changed

Lines changed: 30 additions & 5 deletions

File tree

packages/components/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labkey/components",
3-
"version": "6.44.3",
3+
"version": "6.44.4",
44
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
55
"sideEffects": false,
66
"files": [

packages/components/releaseNotes/components.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# @labkey/components
22
Components, models, actions, and utility functions for LabKey applications and pages
33

4+
### version 6.44.4
5+
*Released*: 2 June 2025
6+
- QueryModel: add isQueryInfoLoaded
7+
- withQueryModels: be more defensive when loading rows and total count
8+
49
### version 6.44.3
510
*Released*: 28 May 2025
611
- Issue 52925: App export to csv/tsv ignores filter with column containing double quote

packages/components/src/public/QueryModel/QueryModel.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ describe('QueryModel', () => {
7777
expect(model.isLoading).toEqual(false);
7878
});
7979

80+
test('isQueryInfoLoaded', () => {
81+
let model = new QueryModel({ schemaQuery: SCHEMA_QUERY });
82+
expect(model.isQueryInfoLoaded).toEqual(false);
83+
model = model.mutate({ queryInfoLoadingState: LoadingState.LOADING });
84+
expect(model.isQueryInfoLoaded).toEqual(false);
85+
model = model.mutate({ queryInfoLoadingState: LoadingState.LOADED });
86+
expect(model.isQueryInfoLoaded).toEqual(true);
87+
model = model.mutate({ queryInfoError: 'Oh no!' });
88+
expect(model.isQueryInfoLoaded).toEqual(false);
89+
});
90+
8091
test('Pagination', () => {
8192
let model = new QueryModel({ schemaQuery: SCHEMA_QUERY }).mutate({
8293
maxRows: 20,

packages/components/src/public/QueryModel/QueryModel.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,13 @@ export class QueryModel {
10441044
return GRID_CHECKBOX_OPTIONS.NONE;
10451045
}
10461046

1047+
/**
1048+
* Returns true if the QueryInfo is loaded and there is not an error
1049+
*/
1050+
get isQueryInfoLoaded(): boolean {
1051+
return this.queryInfoError === undefined && !isLoading(this.queryInfoLoadingState);
1052+
}
1053+
10471054
/**
10481055
* True if either the query info or rows of the QueryModel are still loading.
10491056
*/

packages/components/src/public/QueryModel/withQueryModels.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ export function withQueryModels<Props>(
691691
loadRows = async (id: string, loadSelections = false, selectionsForReplace?: string[]): Promise<void> => {
692692
const { loadRows } = this.props.modelLoader;
693693

694-
if (isLoading(this.state.queryModels[id].queryInfoLoadingState)) {
694+
// Issue 53192
695+
if (!this.state.queryModels[id].isQueryInfoLoaded) {
695696
return;
696697
}
697698

@@ -777,7 +778,8 @@ export function withQueryModels<Props>(
777778
};
778779

779780
loadTotalCount = async (id: string, reloadTotalCount = false): Promise<void> => {
780-
if (isLoading(this.state.queryModels[id].queryInfoLoadingState)) {
781+
// Issue 53192
782+
if (!this.state.queryModels[id].isQueryInfoLoaded) {
781783
return;
782784
}
783785

0 commit comments

Comments
 (0)