carbon-design-system / ibm-products

A Carbon-powered React component library for IBM Products
https://ibm-products.carbondesignsystem.com
Apache License 2.0
92 stars 136 forks source link

Datagrid Infinite scrolling with virtual data (server side fetching) is resetting Search bar when columns change #4782

Open crichtonibm opened 5 months ago

crichtonibm commented 5 months ago

What package(s) are you using?

Detailed description

Using latest IBM Products, and doing server side fetch for data using DataGrid. The infinite scrolling is working well for the most part. But big gap exists with searching. When I enter some text to search, the new data comes down and so I have to recalculate the required widths for the columns. In order for any changes to take affect, I then have to update the columns on the DataGrid. Doing that causes the search bar itself to be reinitialized, leaving me with searching in place, but to real way to clear it, or continue modifying that search.

Is this issue related to a specific component?

DataGrid with infinite scroll and virtual data

What did you expect to happen? What happened instead? What would you like to see changed?

I would expect that updating the columns would not clear the search bar or its current contents

What browser are you working in?

FF/Chrome/Edge

What version of the @carbon/ibm-products (or @carbon/ibm-cloud-cognitive) package are you using? 2.34.0

tom-youd commented 5 months ago

+1 for this - I've noticed the same

elycheea commented 1 month ago

From office hours — could try out autoResetGlobalFilter: false.

Note, will become a bigger usability issue once the team supports SSR.

crichtonibm commented 1 month ago

@elycheea I added the following to my useDatagrid options object, but did not see any change. I also searched the carbon code base in github for autoResetGlobalFilter, and the only hit I got was from this issue. How should I try to enable it?

// Recommended by Carbon folks to prevent clearing of search field when modifying cols datagridOptions.autoResetGlobalFilter = false

crichtonibm commented 1 month ago

I have side stepped the issue by tracking the searched text value in a useState and passing that into the TableToolbarContent in our DataGridActions

amal-k-joy commented 1 week ago

Hi @crichtonibm , Good to know you have found a workaround. Do we need to think of any alternative fix for you?

It would be helpful if you could share a minimum reproduction in code sandbox or stackblitz to analyse further and see how did you update the columns and why this issue caused. FYI, you can pass autoResetGlobalFilter = false to useDatagrid()as below

image

github-actions[bot] commented 3 days ago

This issue is stale because it has been open for 7 days with no activity. Remove the stale label or add a comment, otherwise this issue will be closed in 7 days.