Skip to content

Commit

Permalink
control-bar: hide filter section when there is no filter
Browse files Browse the repository at this point in the history
fixes #5397
  • Loading branch information
vellip authored and goapunk committed Mar 18, 2024
1 parent 1d68ade commit f4c4f54
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions meinberlin/react/contrib/ControlBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ControlBar = () => {
.concat([{ type: 'search', label: term, value: term }])
.filter((f) =>
f.type !== 'ordering' &&
queryParams?.has(f.type)
queryParams?.has(f.type)
)
.map((f) => ({ ...f, value: queryParams.get(f.type) || f.value }))
const nonOrderingFilters = filters.filter((f) => f.type !== 'ordering')
Expand Down Expand Up @@ -126,13 +126,13 @@ export const ControlBar = () => {
</div>
</div>
</fieldset>
<fieldset className="facet">
<legend className="facet__head">
<span className="facet-title">{translated.filters}</span>
</legend>
<div className="facet__body">
<div className="flexgrid grid--3" id="filters">
{nonOrderingFilters.length > 0 && (
{nonOrderingFilters.length > 0 && (
<fieldset className="facet">
<legend className="facet__head">
<span className="facet-title">{translated.filters}</span>
</legend>
<div className="facet__body">
<div className="flexgrid grid--3" id="filters">{
nonOrderingFilters
.slice(0, expandFilters ? nonOrderingFilters.length : 3).map((filter) => (
<ControlBarDropdown
Expand All @@ -143,21 +143,22 @@ export const ControlBar = () => {
onSelectFilter={(choice) => handleFilterChange(filter.type, choice[0])}
/>
))
}
</div>
{nonOrderingFilters.length > 3 && (
<button
onClick={() => setExpandFilters(!expandFilters)}
className="control-bar__filter-btn"
aria-controls="filters"
aria-expanded={expandFilters}
>
<span className={'fa fa-chevron-' + (expandFilters ? 'up' : 'down')} aria-hidden="true" />&nbsp;
{expandFilters ? translated.hideFilters : translated.showFilters}
</button>
)}
</div>
{nonOrderingFilters.length > 3 && (
<button
onClick={() => setExpandFilters(!expandFilters)}
className="control-bar__filter-btn"
aria-controls="filters"
aria-expanded={expandFilters}
>
<span className={'fa fa-chevron-' + (expandFilters ? 'up' : 'down')} aria-hidden="true" />&nbsp;
{expandFilters ? translated.hideFilters : translated.showFilters}
</button>
)}
</div>
</fieldset>
</fieldset>
)}
<div className="form-actions">
<button className="link form-actions__left" onClick={clearFilters}>{translated.reset}</button>
<button className="button button--light form-actions__right control-bar__action-btn" onClick={applyAllFilters}>{translated.filter}</button>
Expand Down

0 comments on commit f4c4f54

Please sign in to comment.