feat(datagrid): redesign filter panel header and row actions#1649
Conversation
- Rename 'Unset' -> 'Clear': calls clearAppliedFilters() (keeps rows, returns to unfiltered); old clearFilterState() moved to 'Remove All Filters' in ... menu - Remove per-row Apply/Applied buttons; 'Apply Only This Filter' added to row context menu via rightMouseDown - Tri-state checkbox in header toggles all filter rows enabled/disabled at once
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cd715afb9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Button("Unset") { | ||
| coordinator.clearFilterState() | ||
| Button("Clear") { | ||
| coordinator.clearAppliedFilters() |
There was a problem hiding this comment.
Defer clearing applied filters until reload is confirmed
When there are unsaved row edits, onUnset() routes to clearFiltersAndReload(), which can be canceled by confirmDiscardChangesIfNeeded. Because this line clears the commit before that confirmation completes, canceling the prompt leaves the grid still running the old filtered query while the panel reports no applied filters and disables Clear. Move the state clear into the confirmed path (or roll it back on cancel) so UI state and the query stay in sync.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e76906c8f1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| Button(role: .destructive) { | ||
| coordinator.clearFilterState() | ||
| onUnset() |
There was a problem hiding this comment.
Avoid reloading when removing unapplied filter rows
When the menu is used while the panel only has draft rows (for example the auto-added blank row before anything has been applied), this still invokes onUnset(), which MainContentView wires to clearFiltersAndReload(). That path prompts to discard unsaved row edits, resets pagination, and runs a query even though no applied filter is affecting the table, so a harmless row cleanup can force a data reload/possible discard. Gate the reload on filterState.hasAppliedFilters and just clear the local rows otherwise.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4daced2a35
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| updated.isEnabled = newState | ||
| coordinator.updateFilter(updated) |
There was a problem hiding this comment.
Keep Clear/Apply available after disabling all applied filters
When the table is filtered via an .all commit and every applied row is enabled, clicking the new header checkbox reaches this path and flips every row to isEnabled = false without reloading. Because hasAppliedFilters is derived from the now-disabled rows, the panel immediately reports no applied filters and disables both Clear and Apply, while the grid is still showing the old filtered query; users then have to remove the rows or re-enable a filter to get back to an unfiltered table. Keep the applied-state controls in sync with the actual query, or allow this toggle to trigger/enable the clear reload path.
Useful? React with 👍 / 👎.
Changes
Implements the new filter panel interaction model:
Clear vs Remove All
clearAppliedFilters()— keeps all filter rows, just removes the applied state so the table returns to unfiltered results....options menu: callsclearFilterState()— removes all filter rows entirely.Per-row Apply moved to context menu
applySoloFilterpath).Tri-state toggle-all checkbox
checkmark.square.fill/square/minus.square.fill) added to the filter panel header.Files:
TablePro/Views/Filter/FilterPanelView.swift,TablePro/Views/Filter/FilterRowView.swiftTest plan
...menu > "Remove All Filters" — all rows removed, table reloads unfiltered