Repository navigation
feat(filters): optionally show the selected value in filter pills - #2159
Conversation
luanfreitasdev
left a comment
There was a problem hiding this comment.
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 ! |
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().
86d5ce5 to
d362e2b
Compare
|
@luanfreitasdev updated the pr |
TL;DR
New opt-in config flag
filter_pill_value(defaultfalse). When enabled, active filter pills show the selected value, e.g.Category: Dessertsinstead ofCategory.Or per table, by overriding a method on the component:
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 selectdataSource, 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
dataSourcequery doesn't run on every page, sort or search.Before
After