Skip to content

Commit 1ec1e32

Browse files
authored
Improve grid rendering at large volumes (#983)
1 parent 7c70f6b commit 1ec1e32

File tree

6 files changed

+46
-28
lines changed

6 files changed

+46
-28
lines changed

.changeset/neat-ads-eat.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ensembleui/react-framework": patch
3+
"@ensembleui/react-runtime": patch
4+
---
5+
6+
Improve grid rendering at large volumes

packages/framework/src/evaluate/context.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mapKeys, merge, keys } from "lodash-es";
1+
import { mapKeys, keys } from "lodash-es";
22
import type { EnsembleContext, EnsembleInterface } from "../shared/ensemble";
33
import type {
44
ApplicationContextDefinition,
@@ -29,22 +29,20 @@ export const createEvaluationContext = ({
2929
context,
3030
}: EvaluationContextProps): EnsembleContext => {
3131
const theme = applicationContext.selectedTheme;
32-
const appInputs = merge(
33-
{},
34-
applicationContext.env,
35-
applicationContext.secrets,
36-
mapKeys(theme?.Tokens ?? {}, (_, key) => key.toLowerCase()),
37-
{ styles: theme?.Styles },
38-
);
32+
const appInputs = {
33+
...applicationContext.env,
34+
...applicationContext.secrets,
35+
...mapKeys(theme?.Tokens ?? {}, (_, key) => key.toLowerCase()),
36+
...{ styles: theme?.Styles },
37+
} as Partial<ApplicationContextDefinition>;
3938

40-
const screenInputs = merge(
41-
{},
42-
screenContext.inputs,
43-
screenContext.widgets
39+
const screenInputs = {
40+
...screenContext.inputs,
41+
...(screenContext.widgets
4442
? Object.fromEntries(widgetStatesToInvokables(screenContext.widgets))
45-
: {},
46-
screenContext.data,
47-
);
43+
: {}),
44+
...screenContext.data,
45+
};
4846

4947
const app = {
5048
languages: applicationContext.application?.languages,
@@ -58,11 +56,12 @@ export const createEvaluationContext = ({
5856
const env = applicationContext.env;
5957

6058
// FIXME: this requires ensemble interface to be built outside of this function
61-
return merge(
62-
{},
63-
{ app, ensemble, env },
64-
appInputs,
65-
screenInputs,
66-
context,
67-
) as EnsembleContext;
59+
return {
60+
app,
61+
ensemble,
62+
env,
63+
...appInputs,
64+
...screenInputs,
65+
...context,
66+
} as EnsembleContext;
6867
};

packages/framework/src/hooks/useEvaluate.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { findExpressions, findHexCodes, findTranslationKeys } from "../shared";
66
import { createBindingAtom } from "../evaluate";
77
import { useCustomScope } from "./useCustomScope";
88

9-
export const useEvaluate = <T extends Record<string, unknown>>(
9+
export const useEvaluate = <T extends { [key: string]: unknown }>(
1010
values?: T,
1111
options?: {
1212
context?: unknown;
@@ -31,7 +31,10 @@ export const useEvaluate = <T extends Record<string, unknown>>(
3131
expressions.map(([name, expr]) => {
3232
const valueAtom = createBindingAtom(
3333
expr,
34-
merge({}, customScope, options?.context),
34+
{
35+
...customScope,
36+
...(options?.context as { [key: string]: unknown }),
37+
},
3538
options?.debugId,
3639
);
3740
return { name, valueAtom };

packages/framework/src/state/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const defaultThemeDefinition = { name: "default" };
88
export interface ApplicationContextDefinition {
99
application: EnsembleAppModel | null;
1010
storage: unknown;
11-
secrets: unknown;
11+
secrets: { [key: string]: unknown };
1212
env: { [key: string]: unknown };
1313
auth: unknown;
1414
user: EnsembleUser | null;

packages/runtime/src/widgets/DataGrid/DataGrid.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export interface DataGridRowTemplate {
8484
}
8585

8686
export interface DataGridScrollable {
87-
scrollHeight?: string;
87+
scrollHeight?: string | number;
8888
scrollWidth?: string;
8989
}
9090

@@ -109,6 +109,7 @@ export type GridProps = {
109109
pageSize?: number;
110110
totalRows?: number;
111111
curPage?: number;
112+
virtual?: boolean;
112113
} & EnsembleWidgetProps<DataGridStyles>;
113114

114115
function djb2Hash(str: string): number {
@@ -501,6 +502,7 @@ export const DataGrid: React.FC<GridProps> = (props) => {
501502
? { display: "none" }
502503
: undefined),
503504
}}
505+
virtual={values?.virtual}
504506
>
505507
{dataColumns.map((col, colIndex) => {
506508
return (

packages/runtime/src/widgets/Form/__tests__/MultiSelect.test.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,16 @@ describe("MultiSelect Widget", () => {
314314

315315
// Wait for the combobox to reflect the selected values
316316
await waitFor(() => {
317-
expect(screen.getByText("Option 1")).toBeVisible();
318-
expect(screen.getByText("Option 3")).toBeVisible();
317+
expect(
318+
screen.getByText("Option 1", {
319+
selector: ".ant-select-selection-item-content",
320+
}),
321+
).toBeVisible();
322+
expect(
323+
screen.getByText("Option 3", {
324+
selector: ".ant-select-selection-item-content",
325+
}),
326+
).toBeVisible();
319327
});
320328
});
321329

0 commit comments

Comments
 (0)