Skip to content

Commit 38fbc5b

Browse files
committed
code cleanup
1 parent c2109e4 commit 38fbc5b

File tree

4 files changed

+34
-35
lines changed

4 files changed

+34
-35
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to `dash-ag-grid` will be documented in this file.
44
This project adheres to [Semantic Versioning](https://semver.org/).
55
Links "DE#nnn" prior to version 2.0 point to the Dash Enterprise closed-source Dash AG Grid repo
66

7+
## UNRELEASED
8+
9+
### Changed
10+
- Component is refactored to be a function component rather than a class
11+
712
## [32.3.0rc0] - 2025-04-15
813

914
### Fixed

src/lib/fragments/AgGrid.react.js

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import {
3737
PROPS_NOT_FOR_AG_GRID,
3838
GRID_DANGEROUS_FUNCTIONS,
3939
OMIT_PROP_RENDER,
40-
OMIT_STATE_RENDER,
4140
OBJ_MAYBE_FUNCTION_OR_MAP_MAYBE_FUNCTIONS,
4241
} from '../utils/propCategories';
4342
import debounce from '../utils/debounce';
@@ -243,21 +242,21 @@ export function DashAgGrid(props) {
243242
(Renderer) => {
244243
const {dangerously_allow_code} = props;
245244

246-
return (props) => (
245+
return (cellProps) => (
247246
<Renderer
248247
setData={(value) => {
249248
customSetProps({
250249
cellRendererData: {
251250
value,
252-
colId: props.column.colId,
253-
rowIndex: props.node.sourceRowIndex,
254-
rowId: props.node.id,
251+
colId: cellProps.column.colId,
252+
rowIndex: cellProps.node.sourceRowIndex,
253+
rowId: cellProps.node.id,
255254
timestamp: Date.now(),
256255
},
257256
});
258257
}}
259258
dangerously_allow_code={dangerously_allow_code}
260-
{...props}
259+
{...cellProps}
261260
></Renderer>
262261
);
263262
},
@@ -290,7 +289,6 @@ export function DashAgGrid(props) {
290289
const selectionEventFired = useRef(false);
291290
const pauseSelections = useRef(false);
292291
const reference = useRef();
293-
// const pendingChanges = useRef(null);
294292
const dataUpdates = useRef(false);
295293
const getDetailParams = useRef();
296294
const getRowsParams = useRef(null);
@@ -1290,7 +1288,7 @@ export function DashAgGrid(props) {
12901288
}
12911289
}, [props.selectedRows, gridApi]);
12921290

1293-
// 1. Handle gridApi initialization - basic setup
1291+
// Handle gridApi initialization - basic setup
12941292
useEffect(() => {
12951293
if (gridApi && gridApi !== prevGridApi) {
12961294
updateColumnWidths(false);
@@ -1302,7 +1300,7 @@ export function DashAgGrid(props) {
13021300
}
13031301
}, [gridApi, prevGridApi, updateColumnWidths, onPaginationChanged]);
13041302

1305-
// 1a. Handle gridApi initialization - expanded groups tracking
1303+
// Handle gridApi initialization - expanded groups tracking
13061304
useEffect(() => {
13071305
if (gridApi && gridApi !== prevGridApi) {
13081306
const groups = {};
@@ -1315,7 +1313,7 @@ export function DashAgGrid(props) {
13151313
}
13161314
}, [gridApi, prevGridApi, setOpenGroups]);
13171315

1318-
// 1b. Handle gridApi initialization - row transactions
1316+
// Handle gridApi initialization - row transactions
13191317
useEffect(() => {
13201318
if (gridApi && gridApi !== prevGridApi && rowTransactionState) {
13211319
rowTransactionState.map((data) =>
@@ -1333,21 +1331,21 @@ export function DashAgGrid(props) {
13331331
syncRowData,
13341332
]);
13351333

1336-
// 1c. Handle gridApi initialization - filter model application
1334+
// Handle gridApi initialization - filter model application
13371335
useEffect(() => {
13381336
if (gridApi && gridApi !== prevGridApi && !isEmpty(props.filterModel)) {
13391337
gridApi.setFilterModel(props.filterModel);
13401338
}
13411339
}, [gridApi, prevGridApi, props.filterModel]);
13421340

1343-
// 1d. Handle gridApi initialization - column state application
1341+
// Handle gridApi initialization - column state application
13441342
useEffect(() => {
13451343
if (gridApi && gridApi !== prevGridApi && props.columnState) {
13461344
setColumnState();
13471345
}
13481346
}, [gridApi, prevGridApi, props.columnState, setColumnState]);
13491347

1350-
// 1e. Handle gridApi initialization - action props with cleanup
1348+
// Handle gridApi initialization - action props with cleanup
13511349
useEffect(() => {
13521350
if (gridApi && gridApi !== prevGridApi) {
13531351
const propsToSet = {};
@@ -1412,7 +1410,7 @@ export function DashAgGrid(props) {
14121410
customSetProps,
14131411
]);
14141412

1415-
// 1f. Handle gridApi initialization - finalization
1413+
// Handle gridApi initialization - finalization
14161414
useEffect(() => {
14171415
if (gridApi && gridApi !== prevGridApi) {
14181416
// Hydrate virtualRowData and finalize setup
@@ -1427,7 +1425,7 @@ export function DashAgGrid(props) {
14271425
updateColumnState,
14281426
]);
14291427

1430-
// 2. Handle columnState push changes
1428+
// Handle columnState push changes
14311429
useEffect(() => {
14321430
if (
14331431
gridApi &&
@@ -1442,7 +1440,7 @@ export function DashAgGrid(props) {
14421440
}
14431441
}, [props.columnState, props.loading_state, gridApi, columnState_push]);
14441442

1445-
// 3. Handle ID changes
1443+
// Handle ID changes
14461444
useEffect(() => {
14471445
if (props.id !== prevProps?.id) {
14481446
if (props.id) {
@@ -1456,7 +1454,7 @@ export function DashAgGrid(props) {
14561454
}
14571455
}, [props.id]);
14581456

1459-
// 4. Handle infinite scrolling datasource
1457+
// Handle infinite scrolling datasource
14601458
useEffect(() => {
14611459
if (isDatasourceLoadedForInfiniteScrolling()) {
14621460
const {rowData, rowCount} = props.getRowsResponse;
@@ -1465,7 +1463,7 @@ export function DashAgGrid(props) {
14651463
}
14661464
}, [props.getRowsResponse]);
14671465

1468-
// 5. Handle master detail response
1466+
// Handle master detail response
14691467
useEffect(() => {
14701468
if (
14711469
props.masterDetail &&
@@ -1481,12 +1479,12 @@ export function DashAgGrid(props) {
14811479
props.detailCellRendererParams,
14821480
]);
14831481

1484-
// 7. Handle dataUpdates reset
1482+
// Handle dataUpdates reset
14851483
useEffect(() => {
14861484
dataUpdates.current = false;
14871485
});
14881486

1489-
// 8. Handle filter model updates
1487+
// Handle filter model updates
14901488
useEffect(() => {
14911489
if (
14921490
gridApi &&
@@ -1498,7 +1496,7 @@ export function DashAgGrid(props) {
14981496
}
14991497
}, [props.filterModel, gridApi, prevGridApi]);
15001498

1501-
// 9. Handle pagination actions
1499+
// Handle pagination actions
15021500
useEffect(() => {
15031501
if (
15041502
gridApi &&
@@ -1509,28 +1507,28 @@ export function DashAgGrid(props) {
15091507
}
15101508
}, [props.paginationGoTo, gridApi, prevGridApi, paginationGoTo]);
15111509

1512-
// 10. Handle scroll actions
1510+
// Handle scroll actions
15131511
useEffect(() => {
15141512
if (gridApi && gridApi === prevGridApi && props.scrollTo) {
15151513
scrollTo();
15161514
}
15171515
}, [props.scrollTo, gridApi, prevGridApi, scrollTo]);
15181516

1519-
// 11. Handle column size updates
1517+
// Handle column size updates
15201518
useEffect(() => {
15211519
if (gridApi && gridApi === prevGridApi && props.columnSize) {
15221520
updateColumnWidths();
15231521
}
15241522
}, [props.columnSize, gridApi, prevGridApi, updateColumnWidths]);
15251523

1526-
// 12. Handle column state reset
1524+
// Handle column state reset
15271525
useEffect(() => {
15281526
if (gridApi && gridApi === prevGridApi && props.resetColumnState) {
15291527
resetColumnState();
15301528
}
15311529
}, [props.resetColumnState, gridApi, prevGridApi, resetColumnState]);
15321530

1533-
// 13. Handle CSV export
1531+
// Handle CSV export
15341532
useEffect(() => {
15351533
if (gridApi && gridApi === prevGridApi && props.exportDataAsCsv) {
15361534
exportDataAsCsv(props.csvExportParams);
@@ -1543,7 +1541,7 @@ export function DashAgGrid(props) {
15431541
exportDataAsCsv,
15441542
]);
15451543

1546-
// 14. Handle row selection actions
1544+
// Handle row selection actions
15471545
useEffect(() => {
15481546
if (gridApi && gridApi === prevGridApi) {
15491547
if (props.selectAll) {
@@ -1567,14 +1565,14 @@ export function DashAgGrid(props) {
15671565
deleteSelectedRows,
15681566
]);
15691567

1570-
// 15. Handle row transactions
1568+
// Handle row transactions
15711569
useEffect(() => {
15721570
if (gridApi && gridApi === prevGridApi && props.rowTransaction) {
15731571
rowTransaction(props.rowTransaction);
15741572
}
15751573
}, [props.rowTransaction, gridApi, prevGridApi, rowTransaction]);
15761574

1577-
// 16. Handle column state updates
1575+
// Handle column state updates
15781576
useEffect(() => {
15791577
if (gridApi && gridApi === prevGridApi) {
15801578
if (props.updateColumnState) {
@@ -1594,12 +1592,8 @@ export function DashAgGrid(props) {
15941592
setColumnState,
15951593
]);
15961594

1597-
// End of hooks
1598-
15991595
const {id, style, className, dashGridOptions, ...restProps} = props;
1600-
16011596
const passingProps = pick(PASSTHRU_PROPS, restProps);
1602-
16031597
const convertedProps = convertAllProps(
16041598
omit(NO_CONVERT_PROPS, {...dashGridOptions, ...restProps})
16051599
);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react';
22
import {LicenseManager} from 'ag-grid-enterprise';
3-
import DashAgGrid, {propTypes} from './AgGrid.react';
3+
import MemoizedAgGrid, {propTypes} from './AgGrid.react';
44

55
export default function DashAgGridEnterprise(props) {
66
const {licenseKey} = props;
77
if (licenseKey) {
88
LicenseManager.setLicenseKey(licenseKey);
99
}
10-
return <DashAgGrid {...props} />;
10+
return <MemoizedAgGrid {...props} />;
1111
}
1212

1313
DashAgGridEnterprise.propTypes = propTypes;

tests/test_cell_data_type_override.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ def test_cd001_cell_data_types_override(dash_duo):
7979
date_input_element = dash_duo.find_element(f'#{grid.id} .ag-date-field-input')
8080
date_input_element.send_keys("01172024" + Keys.ENTER)
8181

82-
# grid.wait_for_cell_text(0, 1, "17/01/2024")
82+
grid.wait_for_cell_text(0, 1, "17/01/2024")

0 commit comments

Comments
 (0)