Skip to content

Commit

Permalink
Merge branch 'main' into update-contributing
Browse files Browse the repository at this point in the history
  • Loading branch information
BSd3v authored Sep 27, 2024
2 parents f2aba90 + 28fafef commit 5b4af3d
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 42 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- name: Generate distribution
run: |
source .venv/bin/activate
uv pip install -r requires-dev.txt -r requires-install.txt
npm i
npm run dist
npm pack && mv *.tgz dist/
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,37 @@ This project adheres to [Semantic Versioning](https://semver.org/).
Links "DE#nnn" prior to version 2.0 point to the Dash Enterprise closed-source Dash AG Grid repo

## unreleased
### Fixed
- [#314](https://github.com/plotly/dash-ag-grid/pull/314)
- locking selenium for tests that were failing due to missing import
- [#313](https://github.com/plotly/dash-ag-grid/pull/313)
- [#312](https://github.com/plotly/dash-ag-grid/issues/312) fixing issue where `scrollTo` was defaulting to not reset the value
- to maintain scroll position during a grid rerender, be sure to use `getRowId`
- fixing side issue where `cellDoubleClicked` was forcing the grid to rerender


## [31.2.0] - 2024-02-25

### Changed
- [#273](https://github.com/plotly/dash-ag-grid/pull/273) increased the timeout for `getApiAsync` to 2 minutes.
- [#281](https://github.com/plotly/dash-ag-grid/pull/281) webpack is now designed to build quicker, excludes `node_modules` and uses a different parser
- [#287](https://github.com/plotly/dash-ag-grid/pull/287) bumping to v`31.2.1` for the grid

### Added
- [#270](https://github.com/plotly/dash-ag-grid/pull/270)
- support for `eventListeners` to be added to the grid that get loaded upon `gridReady`
- `eventListeners` are added upon `gridReady` only, if you need to add or remove other event listeners, please use the `getApi` or `getApiAsync` methods
- added default for `selectedRows` to be `[]`

### Fixed
- [#283](https://github.com/plotly/dash-ag-grid/pull/283)
- `selectedRows` can now be passed along with the `rowData`
- fixes [#274](https://github.com/plotly/dash-ag-grid/issues/274)
- fixes [#282](https://github.com/plotly/dash-ag-grid/issues/282)
- [#287](https://github.com/plotly/dash-ag-grid/pull/287)
- `aggFuncs` can now be passes as an object from the grid to be mapped to functions
- fixes [#278](https://github.com/plotly/dash-ag-grid/issues/278)


## [31.0.1] - 2024-02-07

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Dash AG Grid is a Dash component wrapper for the AG Grid JavaScript package, ena

The underlying AG Grid JavaScript package is a third-party software component developed by [AG Grid Ltd](http://www.ag-grid.com/). Many features are available for free in the AG Grid [Community version](https://github.com/ag-grid/ag-grid). Some features require a paid subscription to the AG Grid Enterprise version ([more info available here](https://www.ag-grid.com/license-pricing.php)). Both the community and enterprise versions are included in this component, but the enterprise features require you to provide a valid AG Grid license key. The demos which use Enterprise features are clearly marked.

<div align="center">
<a href="https://dash.plotly.com/project-maintenance">
<img src="https://dash.plotly.com/assets/images/maintained-by-plotly.png" width="400px" alt="Maintained by Plotly">
</a>
</div>


### Documentation
Please see the [Plotly Dash AG Grid Documentation](https://dash.plotly.com/dash-ag-grid).
Expand Down
66 changes: 39 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-ag-grid",
"version": "31.0.1",
"version": "31.2.0",
"description": "Dash wrapper around AG Grid, the best interactive data grid for the web.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -31,9 +31,9 @@
"dependencies": {
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"ag-grid-community": "31.1.1",
"ag-grid-enterprise": "31.1.1",
"ag-grid-react": "31.1.1",
"ag-grid-community": "31.2.1",
"ag-grid-enterprise": "31.2.1",
"ag-grid-react": "31.2.1",
"@mui/icons-material": "^5.15.7",
"@mui/material": "^5.15.7",
"d3-format": "^3.1.0",
Expand Down
3 changes: 2 additions & 1 deletion requires-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ dash[ci,dev,testing]>=2.0
dash_mantine_components==0.12.1
pyyaml>=5.0
pytest<8.1.0
wheel
wheel
selenium<4.3.0
6 changes: 3 additions & 3 deletions src/lib/fragments/AgGrid.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ export default class DashAgGrid extends Component {
}

if (scrollTo) {
this.scrollTo(scrollTo);
this.scrollTo(false);
propsToSet.scrollTo = null;
}

Expand Down Expand Up @@ -924,7 +924,7 @@ export default class DashAgGrid extends Component {
const {rowModelType, eventListeners} = this.props;

if (rowModelType === 'infinite') {
params.api.setDatasource(this.getDatasource());
params.api.setGridOption('datasource', this.getDatasource());
}

if (eventListeners) {
Expand Down Expand Up @@ -1203,7 +1203,7 @@ export default class DashAgGrid extends Component {
}
}

scrollTo(reset = false) {
scrollTo(reset = true) {
const {gridApi} = this.state;
const {scrollTo, setProps, getRowId} = this.props;
if (!gridApi) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/utils/propCategories.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ export const PROPS_NOT_FOR_AG_GRID = [
'virtualRowData',
'cellValueChanged',
'cellClicked',
'cellDoubleClicked',
'getRowRequest',
'getRowResponse',
'getDetailRequest',
Expand Down Expand Up @@ -364,6 +365,7 @@ export const OMIT_PROP_RENDER = [
'cellClicked',
'paginationInfo',
'cellRendererData',
'cellDoubleClicked',
];

/**
Expand Down
1 change: 1 addition & 0 deletions tests/test_column_drag.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def addGrid(n, s):
return no_update

dash_duo.start_server(app)
dash_duo.driver.set_window_size(1000, 1000)

grid = utils.Grid(dash_duo, "topGrid")
botGrid = utils.Grid(dash_duo, "bottomGrid")
Expand Down
76 changes: 69 additions & 7 deletions tests/test_scroll_to.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from dash import Dash, html, Input, Output
from dash import Dash, html, Input, Output, Patch, State
from dash_ag_grid import AgGrid
import plotly.express as px
import json
from dash.testing.wait import until
import pandas as pd
import pytest
import time

from . import utils

Expand All @@ -20,9 +21,9 @@ def df():
def scroll_to_inputs():
return [
{"rowIndex": 100, "rowPosition": "bottom", "cell": (100, 0)},
{"column": "bronze", "columnPosition": "end", "cell": (100, 8)},
{"rowId": "Elizabeth Beisel12/8/2012", "rowPosition": "top", "cell": (200, 8)},
{"rowIndex": 300, "rowId": 500, "cell": (300, 8)},
{"rowIndex": 100, "column": "bronze", "columnPosition": "end", "cell": (100, 8)},
{"rowId": "Elizabeth Beisel12/8/2012", "column": "bronze", "columnPosition": "end", "rowPosition": "top", "cell": (200, 8)},
{"rowIndex": 300, "column": "bronze", "columnPosition": "end", "cell": (300, 8)},
{
"rowIndex": 400,
"rowId": "Ryan Bayley29/08/2004",
Expand Down Expand Up @@ -86,6 +87,7 @@ def test_st001_scroll_to(dash_duo, df, scroll_to_inputs):
getRowId="params.data.athlete+params.data.date",
),
html.Button(id="btn"),
html.Button(id="btn_columnState"),
html.Div(id="scrollTo-output"),
html.Div(id="scrollTo-input"),
]
Expand All @@ -97,7 +99,19 @@ def test_st001_scroll_to(dash_duo, df, scroll_to_inputs):
Input("grid", "scrollTo"),
)
def display_scrollTo(scroll_to):
return json.dumps(scroll_to)
if scroll_to:
return json.dumps(scroll_to)

@app.callback(
Output('grid', 'columnState'),
Input('btn_columnState', 'n_clicks'),
State('grid', 'columnState'),
prevent_initial_call=True
)
def reset_columnState(n, s):
state = Patch()
state[0]['width'] = s[0]['width'] - n+1
return state

# On click sets up a new value for scrollTo from the fixture scroll_to_inputs
@app.callback(
Expand All @@ -111,6 +125,8 @@ def update_scrollTo(n_clicks):
dash_duo.start_server(app)
grid = utils.Grid(dash_duo, "grid")

action = utils.ActionChains(dash_duo.driver)

# Check that the grid has been loaded successfully
until(lambda: "Michael Phelps" == grid.get_cell(0, 0).text, timeout=3)

Expand All @@ -119,7 +135,8 @@ def update_scrollTo(n_clicks):

y, x = info["cell"]
dash_duo.find_element("#btn").click()
dash_duo.wait_for_text_to_equal("#scrollTo-output", json.dumps(info), timeout=5)
# removing as this no longer works due to resetting the value, [#313](https://github.com/plotly/dash-ag-grid/pull/313)
# dash_duo.wait_for_text_to_equal("#scrollTo-output", json.dumps(info), timeout=5)
until(lambda: grid.get_cell(y, x).is_displayed(), timeout=3)

# row testing
Expand Down Expand Up @@ -161,6 +178,22 @@ def update_scrollTo(n_clicks):
if x - 1 >= 0:
assert not grid.cell_in_viewport(y, x - 1)

# resets the grid
dash_duo.driver.execute_script("""
dash_ag_grid.getApi('grid').ensureIndexVisible(0);
dash_ag_grid.getApi('grid').ensureColumnVisible('athlete');
""")
until(lambda: grid.get_cell(0, 0).is_displayed(), timeout=3)
# make sure grid doesnt change upon double-click
action.double_click(grid.get_cell(0, 0)).perform()
time.sleep(1)
until(lambda: grid.get_cell(0, 0).is_displayed(), timeout=3)
# make sure scroll doesnt fire upon triggered reload by columnState
dash_duo.find_element("#btn_columnState").click()
time.sleep(1)
until(lambda: grid.get_cell(0, 0).is_displayed(), timeout=3)



def test_st002_initial_scroll_to(dash_duo, df):
app = Dash()
Expand All @@ -180,11 +213,23 @@ def test_st002_initial_scroll_to(dash_duo, df):
"rowPosition": "top",
"column": "bronze",
"columnPosition": "end",
},
}
),
html.Button(id="btn_columnState"),
]
)

@app.callback(
Output('grid', 'columnState'),
Input('btn_columnState', 'n_clicks'),
State('grid', 'columnState'),
prevent_initial_call=True
)
def reset_columnState(n, s):
state = Patch()
state[0]['width'] = s[0]['width'] - n + 1
return state

dash_duo.start_server(app)

grid = utils.Grid(dash_duo, "grid")
Expand All @@ -205,3 +250,20 @@ def test_st002_initial_scroll_to(dash_duo, df):
# column testing
assert not grid.cell_in_viewport(y, x + 1)
assert grid.cell_in_viewport(y, x - 1)

action = utils.ActionChains(dash_duo.driver)

# resets the grid
dash_duo.driver.execute_script("""
dash_ag_grid.getApi('grid').ensureIndexVisible(0);
dash_ag_grid.getApi('grid').ensureColumnVisible('athlete');
""")
until(lambda: grid.get_cell(0, 0).is_displayed(), timeout=3)
# make sure grid doesnt change upon double-click
action.double_click(grid.get_cell(0, 0)).perform()
time.sleep(1)
until(lambda: grid.get_cell(0, 0).is_displayed(), timeout=3)
# make sure scroll doesnt fire upon triggered reload by columnState
dash_duo.find_element("#btn_columnState").click()
time.sleep(1)
until(lambda: grid.get_cell(0, 0).is_displayed(), timeout=3)
Loading

0 comments on commit 5b4af3d

Please sign in to comment.