Skip to content

Conversation

ollyhensby
Copy link
Contributor

Issue number of the reported bug or feature request: #451

Describe your changes
When data-model-changed is triggered, call the handleColumnAutoFit method.

Testing performed
Tested that the script shown in the issue runs as planned:

from ipydatagrid import DataGrid
import pandas as pd

df = pd.DataFrame([{"An Important Title": 1}])

grid = DataGrid(df, auto_fit_columns=True, layout={"height": "50px"})
display(grid)

df = pd.DataFrame([{"An Important Title": 1, "Another Title": 2}])
grid.data = df

When setting new data, the columns are now auto fit as expected.

@ollyhensby ollyhensby force-pushed the column-auto-fit-when-setting-data branch 6 times, most recently from 18a47cc to 3908abb Compare October 3, 2023 19:40
@ollyhensby
Copy link
Contributor Author

Looks like the dark-datagrid-nested-hierarchies-update-ipynb-cell-5 and light-datagrid-nested-hierarchies-update-ipynb-cell-5 are failing when comparing snapshots. Not 100% sure why as I ran the notebook locally and they seem to look the exact same? Maybe I am missing something?

@ollyhensby
Copy link
Contributor Author

I think to resolve this I need to recreate the snapshots.

https://github.com/bloomberg/ipydatagrid/blob/main/ui-tests-ipw8/tests/notebooks/datagrid_nested_hierarchies_update.ipynb

In the final cell this is being run:

new_df = pd.DataFrame(columns=nested_df.columns, index=nested_df.index, data=np.arange(-8,8,1).reshape(4,4))
nested_grid.data = new_df

Previously, the grid was not auto-fitting and the snapshot reflects that, whereas now the columns will auto-fit and therefore the snapshot will be different.

I will try create some new snapshots and see if that resolves the visual tests.

@ollyhensby ollyhensby force-pushed the column-auto-fit-when-setting-data branch 2 times, most recently from 74d0e95 to 21a9695 Compare October 11, 2023 19:55
✅ Update datagrid-nested-hierarchies-update-ipynb-cell-5-linux snapshots

Signed-off-by: Oliver Hensby <[email protected]>
@ollyhensby ollyhensby force-pushed the column-auto-fit-when-setting-data branch from 21a9695 to b67699b Compare October 11, 2023 19:56
@ollyhensby
Copy link
Contributor Author

Hi @martinRenou, would you mind taking a quick look at this?

I've just merged the current main branch into my branch and the actions jest / build (20.x) and check / visual-regression-tests-ipw7 are now failing with:

YN0028: The lockfile would have been modified by this install, which is explicitly forbidden.

@vthemelis
Copy link
Contributor

It seems like your changer causes visual regressions? Did you have a look at the updated images?

@ollyhensby
Copy link
Contributor Author

It seems like your changer causes visual regressions? Did you have a look at the updated images?

Hi @vthemelis, thanks for taking the time to look at this.

I have updated the Galata images within this pull request to reflect the changes I've made and ensured the Galata tests pass successfully.

However, two of the Github checks are failing when it tries to install with yarn and I am not sure why that is the case. See my previous comment for the error that is returned.

@alkment
Copy link

alkment commented Nov 27, 2023

@vthemelis any idea why the tests are failing? The PR does not introduce any changes to the dependencies/yarn. Would be great if this could make it's way into master and the next release.

Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaborbernat gaborbernat merged commit a331848 into jupyter-widgets:main Dec 9, 2023
@ollyhensby ollyhensby deleted the column-auto-fit-when-setting-data branch December 21, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants