Skip to content
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

Provide option on store filtering to filter based on modified values #2916

Open
amcclain opened this issue Mar 23, 2022 · 5 comments
Open

Provide option on store filtering to filter based on modified values #2916

amcclain opened this issue Mar 23, 2022 · 5 comments
Assignees
Labels

Comments

@amcclain
Copy link
Member

Currently store filtering works off of committed (unmodified) values only. This is to avoid confusing behavior such as viewing a filtered list of records in a grid, editing one such that it no longer matches the filter, and having that record immediately disappear from view.

However it can be equally confusing in the other direction, where the user edits a record and now expects it to pass/not pass a filter, but does not see that happening and is unsure if their edit "worked."

If we provided the developer with an option to filter based on committed vs. modified, it would allow them to adjust based on the particular use case, and would generally make this behavior more clear / documented.

@amcclain amcclain added the data label Mar 23, 2022
@lbwexler lbwexler added this to the v49 milestone Apr 14, 2022
@amcclain
Copy link
Member Author

@haynesjm42 - doing our weekly ticket triage and still hoping to get this into a release at the end of next week - possible for you to take a look?

@haynesjm42
Copy link
Member

Sure will do

@lbwexler lbwexler modified the milestones: v49, v50, v51 Jul 12, 2022
@saba-mo saba-mo removed this from the v51 milestone Dec 1, 2022
@ghsolomon
Copy link
Contributor

Just encountered this myself when trying to apply filters to a grid with exclusively added records (always starts from an empty state in my case). Was able to work around the issue with the following code, but a flag as described above would certainly be useful here:

private addAction(): RecordActionSpec {
    return {
        icon: Icon.add(),
        intent: 'success',
        text: 'Add',
        actionFn: ({gridModel}) => {
            const id = XH.genId();
            gridModel.store.updateData({add: [{id}]});
            // Add committed record to the store first to allow filtering
            gridModel.store.modifyRecords({id, isModified: true});
            gridModel.beginEditAsync({record: id});
        }
    };
}

@amcclain
Copy link
Member Author

We had a run at this in #2982 but did not reach a satisfactory solution - see PR for much more context. Closing (until it comes up again)

@amcclain amcclain closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2024
@ghsolomon
Copy link
Contributor

This came up again today in a client-app. That app was loading several "uncommitted" records by calling Store.addRecords in order to enable validation, since our RecordValidators only run on uncommitted records. However, it also expected those records to respect filters. For now, that app is going to disable filtering for this grid (validation is more important than filtering in this case), but ideally we could come up with a solution in Hoist. A couple options that have been floated:

  • Add Store.allowFilteringAddedRecords - could be checked by FieldFilter.getTestFn to determine whether to pass adds
  • Add Record.isFilterable to specify at the record-level. This is more complex, and unsure where we'd expect developers to set this.

Related but different issue - only FieldFilter (via its getTestFn) automatically passes adds. FunctionFilter does not unless a developer specifies that behavior via its testFn. We should probably standardize this by having FunctionFilter.getTestFn check if a candidate is an add before delegating to its testFn.

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

No branches or pull requests

5 participants