Skip to content

Commit f6a75ed

Browse files
committed
code cleanup
1 parent c2109e4 commit f6a75ed

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
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: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ export function DashAgGrid(props) {
290290
const selectionEventFired = useRef(false);
291291
const pauseSelections = useRef(false);
292292
const reference = useRef();
293-
// const pendingChanges = useRef(null);
294293
const dataUpdates = useRef(false);
295294
const getDetailParams = useRef();
296295
const getRowsParams = useRef(null);
@@ -1290,7 +1289,7 @@ export function DashAgGrid(props) {
12901289
}
12911290
}, [props.selectedRows, gridApi]);
12921291

1293-
// 1. Handle gridApi initialization - basic setup
1292+
// Handle gridApi initialization - basic setup
12941293
useEffect(() => {
12951294
if (gridApi && gridApi !== prevGridApi) {
12961295
updateColumnWidths(false);
@@ -1302,7 +1301,7 @@ export function DashAgGrid(props) {
13021301
}
13031302
}, [gridApi, prevGridApi, updateColumnWidths, onPaginationChanged]);
13041303

1305-
// 1a. Handle gridApi initialization - expanded groups tracking
1304+
// Handle gridApi initialization - expanded groups tracking
13061305
useEffect(() => {
13071306
if (gridApi && gridApi !== prevGridApi) {
13081307
const groups = {};
@@ -1315,7 +1314,7 @@ export function DashAgGrid(props) {
13151314
}
13161315
}, [gridApi, prevGridApi, setOpenGroups]);
13171316

1318-
// 1b. Handle gridApi initialization - row transactions
1317+
// Handle gridApi initialization - row transactions
13191318
useEffect(() => {
13201319
if (gridApi && gridApi !== prevGridApi && rowTransactionState) {
13211320
rowTransactionState.map((data) =>
@@ -1333,21 +1332,21 @@ export function DashAgGrid(props) {
13331332
syncRowData,
13341333
]);
13351334

1336-
// 1c. Handle gridApi initialization - filter model application
1335+
// Handle gridApi initialization - filter model application
13371336
useEffect(() => {
13381337
if (gridApi && gridApi !== prevGridApi && !isEmpty(props.filterModel)) {
13391338
gridApi.setFilterModel(props.filterModel);
13401339
}
13411340
}, [gridApi, prevGridApi, props.filterModel]);
13421341

1343-
// 1d. Handle gridApi initialization - column state application
1342+
// Handle gridApi initialization - column state application
13441343
useEffect(() => {
13451344
if (gridApi && gridApi !== prevGridApi && props.columnState) {
13461345
setColumnState();
13471346
}
13481347
}, [gridApi, prevGridApi, props.columnState, setColumnState]);
13491348

1350-
// 1e. Handle gridApi initialization - action props with cleanup
1349+
// Handle gridApi initialization - action props with cleanup
13511350
useEffect(() => {
13521351
if (gridApi && gridApi !== prevGridApi) {
13531352
const propsToSet = {};
@@ -1412,7 +1411,7 @@ export function DashAgGrid(props) {
14121411
customSetProps,
14131412
]);
14141413

1415-
// 1f. Handle gridApi initialization - finalization
1414+
// Handle gridApi initialization - finalization
14161415
useEffect(() => {
14171416
if (gridApi && gridApi !== prevGridApi) {
14181417
// Hydrate virtualRowData and finalize setup
@@ -1427,7 +1426,7 @@ export function DashAgGrid(props) {
14271426
updateColumnState,
14281427
]);
14291428

1430-
// 2. Handle columnState push changes
1429+
// Handle columnState push changes
14311430
useEffect(() => {
14321431
if (
14331432
gridApi &&
@@ -1442,7 +1441,7 @@ export function DashAgGrid(props) {
14421441
}
14431442
}, [props.columnState, props.loading_state, gridApi, columnState_push]);
14441443

1445-
// 3. Handle ID changes
1444+
// Handle ID changes
14461445
useEffect(() => {
14471446
if (props.id !== prevProps?.id) {
14481447
if (props.id) {
@@ -1456,7 +1455,7 @@ export function DashAgGrid(props) {
14561455
}
14571456
}, [props.id]);
14581457

1459-
// 4. Handle infinite scrolling datasource
1458+
// Handle infinite scrolling datasource
14601459
useEffect(() => {
14611460
if (isDatasourceLoadedForInfiniteScrolling()) {
14621461
const {rowData, rowCount} = props.getRowsResponse;
@@ -1465,7 +1464,7 @@ export function DashAgGrid(props) {
14651464
}
14661465
}, [props.getRowsResponse]);
14671466

1468-
// 5. Handle master detail response
1467+
// Handle master detail response
14691468
useEffect(() => {
14701469
if (
14711470
props.masterDetail &&
@@ -1481,12 +1480,12 @@ export function DashAgGrid(props) {
14811480
props.detailCellRendererParams,
14821481
]);
14831482

1484-
// 7. Handle dataUpdates reset
1483+
// Handle dataUpdates reset
14851484
useEffect(() => {
14861485
dataUpdates.current = false;
14871486
});
14881487

1489-
// 8. Handle filter model updates
1488+
// Handle filter model updates
14901489
useEffect(() => {
14911490
if (
14921491
gridApi &&
@@ -1498,7 +1497,7 @@ export function DashAgGrid(props) {
14981497
}
14991498
}, [props.filterModel, gridApi, prevGridApi]);
15001499

1501-
// 9. Handle pagination actions
1500+
// Handle pagination actions
15021501
useEffect(() => {
15031502
if (
15041503
gridApi &&
@@ -1509,28 +1508,28 @@ export function DashAgGrid(props) {
15091508
}
15101509
}, [props.paginationGoTo, gridApi, prevGridApi, paginationGoTo]);
15111510

1512-
// 10. Handle scroll actions
1511+
// Handle scroll actions
15131512
useEffect(() => {
15141513
if (gridApi && gridApi === prevGridApi && props.scrollTo) {
15151514
scrollTo();
15161515
}
15171516
}, [props.scrollTo, gridApi, prevGridApi, scrollTo]);
15181517

1519-
// 11. Handle column size updates
1518+
// Handle column size updates
15201519
useEffect(() => {
15211520
if (gridApi && gridApi === prevGridApi && props.columnSize) {
15221521
updateColumnWidths();
15231522
}
15241523
}, [props.columnSize, gridApi, prevGridApi, updateColumnWidths]);
15251524

1526-
// 12. Handle column state reset
1525+
// Handle column state reset
15271526
useEffect(() => {
15281527
if (gridApi && gridApi === prevGridApi && props.resetColumnState) {
15291528
resetColumnState();
15301529
}
15311530
}, [props.resetColumnState, gridApi, prevGridApi, resetColumnState]);
15321531

1533-
// 13. Handle CSV export
1532+
// Handle CSV export
15341533
useEffect(() => {
15351534
if (gridApi && gridApi === prevGridApi && props.exportDataAsCsv) {
15361535
exportDataAsCsv(props.csvExportParams);
@@ -1543,7 +1542,7 @@ export function DashAgGrid(props) {
15431542
exportDataAsCsv,
15441543
]);
15451544

1546-
// 14. Handle row selection actions
1545+
// Handle row selection actions
15471546
useEffect(() => {
15481547
if (gridApi && gridApi === prevGridApi) {
15491548
if (props.selectAll) {
@@ -1567,14 +1566,14 @@ export function DashAgGrid(props) {
15671566
deleteSelectedRows,
15681567
]);
15691568

1570-
// 15. Handle row transactions
1569+
// Handle row transactions
15711570
useEffect(() => {
15721571
if (gridApi && gridApi === prevGridApi && props.rowTransaction) {
15731572
rowTransaction(props.rowTransaction);
15741573
}
15751574
}, [props.rowTransaction, gridApi, prevGridApi, rowTransaction]);
15761575

1577-
// 16. Handle column state updates
1576+
// Handle column state updates
15781577
useEffect(() => {
15791578
if (gridApi && gridApi === prevGridApi) {
15801579
if (props.updateColumnState) {
@@ -1594,12 +1593,8 @@ export function DashAgGrid(props) {
15941593
setColumnState,
15951594
]);
15961595

1597-
// End of hooks
1598-
15991596
const {id, style, className, dashGridOptions, ...restProps} = props;
1600-
16011597
const passingProps = pick(PASSTHRU_PROPS, restProps);
1602-
16031598
const convertedProps = convertAllProps(
16041599
omit(NO_CONVERT_PROPS, {...dashGridOptions, ...restProps})
16051600
);

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)