What happens
reload() from the data view context does nothing in DataGrid, HasManyDataGrid and SelectDataView. The list is never fetched again, so the toolbar's reload button (DataViewReloadTrigger) and any useDataViewReload() call after a row action leave stale rows on screen.
All three implement it as a counter that nothing reads (packages/bindx-dataview/src/DataGrid.tsx:144, same in HasManyDataGrid.tsx:251 and select/SelectDataView.tsx:199):
const [, setReloadCounter] = useState(0)
const reload = useCallback((): void => {
setReloadCounter(c => c + 1)
}, [])
The counter is not passed to useEntityList (queryKey) or useEntityCount (refreshToken), so the re-render it causes hits the same cached query.
Seen on 0.1.52 and on main (78c1712).
Repro
- A
DataGrid over tasks filtered to open ones (finishedAt: { isNull: true }).
- A row action that sets
finishedAt through a separate mutation (not the grid's own store), then calls useDataViewReload()().
- The finished task stays in the list until the page is reloaded. Clicking the toolbar reload button changes nothing either.
Expected
reload() refetches the current page and the total count with the current filter, sort and paging, keeping the rows on screen while it loads (loader state refreshing).
Possible fix
Fold the counter into the key the list query is cached under and into the count's refresh token, e.g. in DataGrid:
const [reloadCounter, setReloadCounter] = useState(0)
const result = useEntityList(entity, { ..., queryKey: `${setup.queryKey}:${reloadCounter}` })
const { count } = useEntityCount(entity, { filter: setup.combinedFilter, refreshToken: setup.paging.totalCountRefreshToken + reloadCounter })
and the equivalent for the paginateRelation load in HasManyDataGrid and for SelectDataView.
Workaround we use
Changing the grid's filter with a match-all condition that carries a counter (id: { notEq: '00000000-0000-0000-0000-<counter>' }), which forces a new query: prosam-crm admin/src/components/data-grid/reload.ts.
What happens
reload()from the data view context does nothing inDataGrid,HasManyDataGridandSelectDataView. The list is never fetched again, so the toolbar's reload button (DataViewReloadTrigger) and anyuseDataViewReload()call after a row action leave stale rows on screen.All three implement it as a counter that nothing reads (
packages/bindx-dataview/src/DataGrid.tsx:144, same inHasManyDataGrid.tsx:251andselect/SelectDataView.tsx:199):The counter is not passed to
useEntityList(queryKey) oruseEntityCount(refreshToken), so the re-render it causes hits the same cached query.Seen on 0.1.52 and on
main(78c1712).Repro
DataGridover tasks filtered to open ones (finishedAt: { isNull: true }).finishedAtthrough a separate mutation (not the grid's own store), then callsuseDataViewReload()().Expected
reload()refetches the current page and the total count with the current filter, sort and paging, keeping the rows on screen while it loads (loader staterefreshing).Possible fix
Fold the counter into the key the list query is cached under and into the count's refresh token, e.g. in
DataGrid:and the equivalent for the
paginateRelationload inHasManyDataGridand forSelectDataView.Workaround we use
Changing the grid's
filterwith a match-all condition that carries a counter (id: { notEq: '00000000-0000-0000-0000-<counter>' }), which forces a new query: prosam-crmadmin/src/components/data-grid/reload.ts.