Skip to content

feat(filters): optionally show the selected value in filter pills - #2159

Merged
luanfreitasdev merged 2 commits into
Power-Components:7.xfrom
0z3:feat/filter-pill-value
Nov 13, 2026
Merged

luanfreitasdev merged 2 commits into
Power-Components:7.xfrom
0z3:feat/filter-pill-value

Conversation

@0z3

@0z3 0z3 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR

New opt-in config flag filter_pill_value (default false). When enabled, active filter pills show the selected value, e.g. Category: Desserts instead of Category.

// config/livewire-powergrid.php
'filter_pill_value' => true,

Or per table, by overriding a method on the component:

public function showFilterPillValue(): bool
{
    return true;
}

Covers select/enum (option label), multi-select, boolean (true/false labels), number and date ranges, and valueless operators (Is empty). Also fixes inline resolution blanking the declared select dataSource, which made option labels unresolvable later in the same request.

The pill value is resolved only when a filter's value changes and reused on later renders, so a select dataSource query doesn't run on every page, sort or search.

Before

before

After

after

@luanfreitasdev luanfreitasdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Nice feature. Two things before merging:

Performance: syncFilterPills() runs on every request, and with the flag on, rebuildEnabledFilters() re-executes each active select filter’s dataSource closure. When resolveFilters() also runs in that request, the closure executes twice. This bypasses the lazy panel (filterPanelLoaded) and inlineFiltersResolved short-circuits, so a City::all() datasource now runs on every page, sort and search. Could the label be resolved once when the filter value changes (e.g. in commitFilters()) and stored with the pill, instead of on every render?

Per-table toggle: the docs suggest calling config([...]) in a component’s boot(). That mutates global config. Livewire 4 bundles updates for several components into one request, so the flag leaks into the other tables on the page. A component-level property or method would be scoped correctly.

@0z3

0z3 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Nice feature. Two things before merging:

Performance: syncFilterPills() runs on every request, and with the flag on, rebuildEnabledFilters() re-executes each active select filter’s dataSource closure. When resolveFilters() also runs in that request, the closure executes twice. This bypasses the lazy panel (filterPanelLoaded) and inlineFiltersResolved short-circuits, so a City::all() datasource now runs on every page, sort and search. Could the label be resolved once when the filter value changes (e.g. in commitFilters()) and stored with the pill, instead of on every render?

Per-table toggle: the docs suggest calling config([...]) in a component’s boot(). That mutates global config. Livewire 4 bundles updates for several components into one request, so the flag leaks into the other tables on the page. A component-level property or method would be scoped correctly.

yes checking it out !

0z3 added 2 commits November 13, 2026 16:06
Adds the 'filter_pill_value' config flag (default false). When enabled,
each active filter pill renders 'Label: value' (select option labels,
boolean labels, number/date ranges, valueless operators).

Also stops inline filter resolution from blanking the declared select
dataSource, so option labels stay resolvable within the same request.
…able toggle

Pills store a hash of each filter record and reuse the resolved value
while it is unchanged, so a select dataSource no longer runs on every
render (page, sort, search).

Add PowerGridComponent::showFilterPillValue() to enable the pill value
per table instead of mutating global config in boot().
@0z3
0z3 force-pushed the feat/filter-pill-value branch from 86d5ce5 to d362e2b Compare November 13, 2026 15:12
@0z3

0z3 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@luanfreitasdev updated the pr

@luanfreitasdev
luanfreitasdev merged commit 73f4aef into Power-Components:7.x Nov 13, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants