Skip to content

Commit 9420573

Browse files
ianthomas23martinRenou
authored andcommitted
Fix initial click in Filter by Value dialog
1 parent 863cce4 commit 9420573

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

js/core/filterMenu.ts

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -287,26 +287,29 @@ export class InteractiveFilterDialog extends BoxPanel {
287287
* "Select all" button should be ticked when
288288
* opening the filter by value menu.
289289
*/
290-
updateSelectAllCheckboxState() {
290+
async updateSelectAllCheckboxState() {
291291
if (!this.userInteractedWithDialog && !this.hasFilter) {
292292
this._selectAllCheckbox.checked = true;
293293
return;
294294
}
295295

296-
this._model.uniqueValues(this._region, this._column).then((uniqueVals) => {
297-
let showAsChecked = true;
298-
for (const value of uniqueVals) {
299-
// If there is a unique value which is not present in the state then it is
300-
// not ticked, and therefore we should not tick the "Select all" checkbox.
301-
if (
302-
!this._uniqueValueStateManager.has(this._region, this._column, value)
303-
) {
304-
showAsChecked = false;
305-
break;
306-
}
296+
const uniqueVals = await this._model.uniqueValues(
297+
this._region,
298+
this._column,
299+
);
300+
301+
let showAsChecked = true;
302+
for (const value of uniqueVals) {
303+
// If there is a unique value which is not present in the state then it is
304+
// not ticked, and therefore we should not tick the "Select all" checkbox.
305+
if (
306+
!this._uniqueValueStateManager.has(this._region, this._column, value)
307+
) {
308+
showAsChecked = false;
309+
break;
307310
}
308-
this._selectAllCheckbox.checked = showAsChecked;
309-
});
311+
}
312+
this._selectAllCheckbox.checked = showAsChecked;
310313
}
311314

312315
/**
@@ -1128,20 +1131,18 @@ export class InteractiveFilterDialog extends BoxPanel {
11281131
];
11291132
}
11301133

1131-
addRemoveAllUniqueValuesToState(add: boolean) {
1132-
this.model.uniqueValues(this._region, this._column).then((uniqueVals) => {
1133-
for (const value of uniqueVals) {
1134-
if (add) {
1135-
this._uniqueValueStateManager.add(this._region, this._column, value);
1136-
} else {
1137-
this._uniqueValueStateManager.remove(
1138-
this._region,
1139-
this._column,
1140-
value,
1141-
);
1142-
}
1134+
async addRemoveAllUniqueValuesToState(add: boolean) {
1135+
const uniqueVals = await this.model.uniqueValues(
1136+
this._region,
1137+
this._column,
1138+
);
1139+
for (const value of uniqueVals) {
1140+
if (add) {
1141+
this._uniqueValueStateManager.add(this._region, this._column, value);
1142+
} else {
1143+
this._uniqueValueStateManager.remove(this._region, this._column, value);
11431144
}
1144-
});
1145+
}
11451146
}
11461147

11471148
/**
@@ -1510,7 +1511,7 @@ class UniqueValueGridMouseHandler extends BasicMouseHandler {
15101511
this._uniqueValuesSelectionState.add(region, colIndex, value);
15111512
}
15121513

1513-
// Updating the "Select all" chexboox if needed
1514+
// Updating the "Select all" checkbox if needed
15141515
this._filterDialog.updateSelectAllCheckboxState();
15151516
};
15161517

@@ -1519,9 +1520,10 @@ class UniqueValueGridMouseHandler extends BasicMouseHandler {
15191520
!this._filterDialog.hasFilter &&
15201521
!this._filterDialog.userInteractedWithDialog
15211522
) {
1522-
this._filterDialog.addRemoveAllUniqueValuesToState(true);
1523-
this._filterDialog.userInteractedWithDialog = true;
1524-
updateCheckState();
1523+
this._filterDialog.addRemoveAllUniqueValuesToState(true).then(() => {
1524+
this._filterDialog.userInteractedWithDialog = true;
1525+
updateCheckState();
1526+
});
15251527
} else {
15261528
updateCheckState();
15271529
}

0 commit comments

Comments
 (0)