diff --git a/CHANGELOG.md b/CHANGELOG.md index 086a715b..0252802f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ Links "DE#nnn" prior to version 2.0 point to the Dash Enterprise closed-source D ### Added - [#453](https://github.com/plotly/dash-ag-grid/pull/453) Test for changelog entry +### Changed +- [#452](https://github.com/plotly/dash-ag-grid/pull/452) + - Added test for `OBJ_MAYBE_FUNCTION_OR_MAP_MAYBE_FUNCTIONS` to test that the value is an object before parsing, + - this allows for reused keys to not comply with being an object + ## [35.2.0] - 2026-04-03 ### Added diff --git a/src/lib/fragments/AgGrid.react.js b/src/lib/fragments/AgGrid.react.js index 170a1b95..6f7dad3a 100644 --- a/src/lib/fragments/AgGrid.react.js +++ b/src/lib/fragments/AgGrid.react.js @@ -529,24 +529,26 @@ export function DashAgGrid(props) { }); } if (OBJ_MAYBE_FUNCTION_OR_MAP_MAYBE_FUNCTIONS[target]) { - if ('function' in value) { - if (typeof value.function === 'string') { - return convertMaybeFunctionNoParams(value); - } - } - return map((v) => { - if ( - typeof v === 'object' && - v !== null && - !Array.isArray(v) - ) { - if (typeof v.function === 'string') { - return convertMaybeFunctionNoParams(v); + if (typeof value === 'object') { + if ('function' in value) { + if (typeof value.function === 'string') { + return convertMaybeFunctionNoParams(value); } - return convertCol(v); } - return v; - }, value); + return map((v) => { + if ( + typeof v === 'object' && + v !== null && + !Array.isArray(v) + ) { + if (typeof v.function === 'string') { + return convertMaybeFunctionNoParams(v); + } + return convertCol(v); + } + return v; + }, value); + } } if ( COLUMN_NESTED_FUNCTIONS[target] && diff --git a/tests/test_cell_data_type_override.py b/tests/test_cell_data_type_override.py index 6771394d..23e12363 100644 --- a/tests/test_cell_data_type_override.py +++ b/tests/test_cell_data_type_override.py @@ -2,6 +2,7 @@ import dash_ag_grid as dag from dash import Dash, html +import plotly.express as px from . import utils def test_cd001_cell_data_types_override(enforced_locale, dash_duo): @@ -146,4 +147,29 @@ def test_cd002_column_types_formatting(dash_duo): input_el = dash_duo.find_element("#grid-column-types .ag-input-field-input") input_el.send_keys("0.2" + Keys.ENTER) - grid.wait_for_cell_text(0, 1, "0.200") \ No newline at end of file + grid.wait_for_cell_text(0, 1, "0.200") + +def test_cd003_column_types_overriding(dash_duo): + df = px.data.iris() + + app = Dash(__name__) + + app.layout = html.Div( + [ + dag.AgGrid( + rowData=df.to_dict("records"), + columnDefs=[{"field": c} for c in df.columns], + dashGridOptions={ + "dataTypeDefinitions": { + "number": { + "columnTypes": "rightAligned", + } + } + }, + id='grid' + ) + ] + ) + + dash_duo.start_server(app) + grid = utils.Grid(dash_duo, "grid") \ No newline at end of file