Skip to content

Add removeConfigs to perspective-select for explicit filter removal#3133

Merged
texodus merged 1 commit intoperspective-dev:masterfrom
sinistersnare:feature/workspace-filtering-improvements
Mar 9, 2026
Merged

Add removeConfigs to perspective-select for explicit filter removal#3133
texodus merged 1 commit intoperspective-dev:masterfrom
sinistersnare:feature/workspace-filtering-improvements

Conversation

@sinistersnare
Copy link
Contributor

@sinistersnare sinistersnare commented Mar 4, 2026

The workspace's global filter propagation had no mechanism to remove a filter applied to a column outside the master viewer's group_by, split_by, or filter config.

When a master viewer fires a perspective-select event, _filterViewer builds a candidates set from those three fields and uses it to decide which slave filters to overwrite on the next event. Any filter applied to a column not in candidates was permanently stuck on slave viewers — no UI action or subsequent event dispatch could remove it.

This PR changes the API of the perspective-select event, it is a BREAKING CHANGE for the API. Before, the detail in the event took a config that was a ViewConfigUpdate which lead to this confusing behavior. This PR replaces this object with a class and removes the field while introducing removeConfigs: ViewConfigUpdate[], insertConfigs: ViewConfigUpdate[] to make the new behavior explicit.

The removeConfigs explicitly removes filters from slave viewers by the filter, bypassing the candidates check. It also replaces the untyped event detail object with a typed PerspectiveSelectDetail class (moved to and then exported from @perspective-dev/viewer), which is a breaking change for any consumers reading the config field from perspective-select events.

The old configs field is now called insertConfigs, and is applied after removeConfigs removes the relevant fields.

Breaking change: the config field on perspective-select event details is replaced by insertConfigs: ViewConfigUpdate[] and removeConfigs: ViewConfigUpdate[]. Both viewer-datagrid and viewer-d3fc have been updated accordingly.

PerspectiveWorkspaceProps in the React package is also exported (it was previously unexported).

Testing

To test this functionality I have verified it via the following manual test, but there are also automated tests in the commit.

Step 1 — Go to the Movies blocks example:
http://localhost:8080/src/movies/index.html

Step 2 — Click "Warner Bros." in the master datagrid to select it.

Slaves filter to Distributor == "Warner Bros.". Standard behavior.

Step 3 — Stack an MPAA Rating filter on top (paste in console):

// Note that in production uses of this event, 
// you should be using the `PerspectiveSelectDetail` 
// class from `@perspective-dev/viewer`.
document.querySelector(".workspace-master-widget").dispatchEvent(
    new CustomEvent("perspective-select", {
        bubbles: true,
        composed: true,
        detail: {
            selected: true,
            row: {},
            column_names: ["Distributor", "MPAA Rating"],
            insertConfigs: [{
                filter: [
                    ["Distributor", "==", "Warner Bros."],
                    ["MPAA Rating", "==", "PG-13"],
                ],
            }],
            removeConfigs: [],
        },
    })
);

Slaves now show only Warner Bros. PG-13 films.

Step 4 — Click "Warner Bros." again to deselect.

Distributor clears as expected. But MPAA Rating == "PG-13" is stuck — it is not in the master's group_by/split_by/filter, so the candidates mechanism cannot reach it. There is no UI action that can remove it with the old behavior.

Step 5 — Use removeConfigs to clear it (new behavior):

document.querySelector(".workspace-master-widget").dispatchEvent(
    new CustomEvent("perspective-select", {
        bubbles: true,
        composed: true,
        detail: {
            selected: true,
            row: {},
            column_names: [],
            insertConfigs: [],
            removeConfigs: [{
                filter: [["MPAA Rating", "==", "PG-13"]],
            }],
        },
    })
);

Slaves return to fully unfiltered. The heatmap should show the complete dataset again.

This PR was initially written with AI assistance, but was reviewed, edited (adding better types and fixing problems that the AI was unable to work out), and manually tested by me.

@sinistersnare sinistersnare force-pushed the feature/workspace-filtering-improvements branch from e3c474e to 105ea6e Compare March 5, 2026 19:56
@sinistersnare sinistersnare changed the title Workspace global-filter removal via tombstone entries Add removeConfigs to perspective-select for explicit filter removal Mar 5, 2026
@sinistersnare sinistersnare changed the title Add removeConfigs to perspective-select for explicit filter removal Add removeConfigs to perspective-select for explicit filter removal Mar 5, 2026
@sinistersnare sinistersnare changed the title Add removeConfigs to perspective-select for explicit filter removal Add removeConfigs to perspective-select for explicit filter removal Mar 5, 2026
Add removeConfigs support to perspective-select for off-candidates filter removal

The workspace's global filter propagation could not remove filters applied to
columns outside the master viewer's group_by/split_by/filter candidates set.
Once such a filter was applied it was permanently stuck on slave viewers.

Introduces removeConfigs: ViewConfigUpdate[] on the perspective-select event
detail, which explicitly removes filters from slave viewers by column regardless
of the candidates set. Also replaces the untyped event detail object with a
typed PerspectiveSelectDetail class exported from @perspective-dev/viewer.

Breaking change: the config field on perspective-select event details is
replaced by insertConfigs and removeConfigs. viewer-datagrid and viewer-d3fc
are updated accordingly.

Signed-off-by: Davis Silverman <davis@thedav.is>
@sinistersnare sinistersnare force-pushed the feature/workspace-filtering-improvements branch from 105ea6e to db9bb67 Compare March 5, 2026 20:14
Copy link
Member

@texodus texodus left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks good!

@texodus texodus added enhancement Feature requests or improvements breaking labels Mar 9, 2026
@texodus texodus merged commit 96b5faa into perspective-dev:master Mar 9, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking enhancement Feature requests or improvements

Development

Successfully merging this pull request may close these issues.

2 participants