Skip to content

Commit 6ec7ce4

Browse files
committed
fix: defer selection to correct moment of execution
1 parent a77208e commit 6ec7ce4

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

packages/pluggableWidgets/datagrid-web/typings/DatagridProps.d.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ import { ComponentType, CSSProperties, ReactNode } from "react";
77
import { ActionValue, DynamicValue, EditableValue, ListValue, ListActionValue, ListAttributeValue, ListAttributeListValue, ListExpressionValue, ListWidgetValue, SelectionSingleValue, SelectionMultiValue } from "mendix";
88
import { Big } from "big.js";
99

10-
export type ItemSelectionMethodEnum = "checkbox" | "rowClick";
11-
12-
export type ItemSelectionModeEnum = "toggle" | "clear";
13-
14-
export type LoadingTypeEnum = "spinner" | "skeleton";
15-
1610
export type ShowContentAsEnum = "attribute" | "dynamicText" | "customContent";
1711

1812
export type ExportTypeEnum = "default" | "number" | "date" | "boolean";
@@ -106,15 +100,7 @@ export interface DatagridContainerProps {
106100
tabIndex?: number;
107101
datasource: ListValue;
108102
refreshInterval: number;
109-
itemSelection?: SelectionSingleValue | SelectionMultiValue;
110-
itemSelectionMethod: ItemSelectionMethodEnum;
111103
autoSelect: boolean;
112-
itemSelectionMode: ItemSelectionModeEnum;
113-
showSelectAllToggle: boolean;
114-
keepSelection: boolean;
115-
clearSelectionButtonLabel?: DynamicValue<string>;
116-
loadingType: LoadingTypeEnum;
117-
refreshIndicator: boolean;
118104
columns: ColumnsType[];
119105
columnsFilterable: boolean;
120106
onClickTrigger: OnClickTriggerEnum;
@@ -174,15 +160,7 @@ export interface DatagridPreviewProps {
174160
translate: (text: string) => string;
175161
datasource: {} | { caption: string } | { type: string } | null;
176162
refreshInterval: number | null;
177-
itemSelection: "None" | "Single" | "Multi";
178-
itemSelectionMethod: ItemSelectionMethodEnum;
179163
autoSelect: boolean;
180-
itemSelectionMode: ItemSelectionModeEnum;
181-
showSelectAllToggle: boolean;
182-
keepSelection: boolean;
183-
clearSelectionButtonLabel: string;
184-
loadingType: LoadingTypeEnum;
185-
refreshIndicator: boolean;
186164
columns: ColumnsPreviewType[];
187165
columnsFilterable: boolean;
188166
onClickTrigger: OnClickTriggerEnum;

packages/shared/widget-plugin-grid/src/selection/createSelectionHelper.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,19 @@ export function createSelectionHelper(
6060
}
6161
if (helper.type === "Single" && config.autoSelect) {
6262
const dispose = autorun(() => {
63-
const firstItem = gate.props.datasource.items?.[0];
64-
if (!firstItem) return;
65-
helper.reduceTo(firstItem);
66-
dispose();
63+
const { datasource, selection } = gate.props;
64+
const firstItem = datasource.items?.[0];
65+
66+
if (datasource.status === "available") {
67+
if (firstItem && !selection?.selection) {
68+
setTimeout(() => {
69+
if (!gate.props.selection?.selection) {
70+
(gate.props.selection as SelectionSingleValue)?.setSelection(firstItem);
71+
}
72+
}, 0);
73+
}
74+
dispose();
75+
}
6776
});
6877
add(dispose);
6978
}

0 commit comments

Comments
 (0)