Skip to content

CardView: dataController -> paging in the remote OData DataSource not working #29877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 25_1
Choose a base branch
from

Conversation

pomahtri
Copy link
Contributor

@pomahtri pomahtri commented May 15, 2025

PR consist of two commits:

fix: bug

Direct fix of the bug described in the card.

Problem: each time some loadOption is changed, we call effect to pass changed values to dataSource and call .load if we need it.
In case of filtering, we were passing the displayFilter.value ?? null to dataSource, but the displayField could also be undefined. In result, we passed each time the 'null' value, but we were comparing it with undefined each time.

Because of this, filter was set each time when any loadOption was changed, and there's internal dataSource logic to drop pageIndex after filtering is changed (since it could lead to changes in totalCount)

fix: getCombinedFilter

I noticed that we didn't have proper logic for getCombinedFilter and fixed it

When we were syncing cardview's display filter to dataSource filter, we were just calling dataSource.filter(displayFilter). However, dataGrid behaves in different way:

Filter, specified in DataSource, is never changed, and is used as 'initial top-level filter'. When we set filter by UI, displayFilter (called additionalFilter in DataGrid) was combined to filter in DataSource, not overwrite it.

I added combineFilter method, used it in customizeStoreLoadOptions callback and fixed public method getCombinedFilter

@pomahtri pomahtri requested a review from a team May 15, 2025 06:22
@pomahtri pomahtri self-assigned this May 15, 2025
@pomahtri pomahtri added the 25_1 label May 15, 2025
};
};

describe('regressions', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rename the description to 'DataController' ? I think current name isn't suitable and doesn't follow the way other testing files have their descriptions.

Comment on lines +238 to +245
if (!equalByValue(
this.previousDisplayFilter ?? null,
displayFilter ?? null,
{
maxDepth: FILTER_OBJ_COMPARE_DEPTH,
strict: true,
},
)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (!equalByValue(
this.previousDisplayFilter ?? null,
displayFilter ?? null,
{
maxDepth: FILTER_OBJ_COMPARE_DEPTH,
strict: true,
},
)) {
const filterChanged = !equalByValue(
this.previousDisplayFilter ?? null,
displayFilter ?? null,
{
maxDepth: FILTER_OBJ_COMPARE_DEPTH,
strict: true,
},
);
if (filterChanged) {

Comment on lines +185 to +186
describe('when displayFilter and filter from dataSource are empty', () => {
it('should return empty filter', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just?:

Suggested change
describe('when displayFilter and filter from dataSource are empty', () => {
it('should return empty filter', () => {
it('should return empty filter when displayFilter and filter from dataSource are empty', () => {

I doubt that there will be any other tests in this describe block.

dataSourceFilter: ['a', '=', 123],
columnFilterValues: [1, 2],
});
expect(gridCore.getCombinedFilter()).toMatchInlineSnapshot(`
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use toEqual here too? Just to be consistent

dataSourceFilter: undefined,
columnFilterValues: [1, 2],
});
expect(gridCore.getCombinedFilter()).toMatchInlineSnapshot('undefined');
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use toEqual/toBe here too? Is there any specific reason why toMatchInlineSnapshot was used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants