-
Notifications
You must be signed in to change notification settings - Fork 34
refactor: move collapsible logic into shared-filter for checkbox filters #2151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abdimo101
wants to merge
3
commits into
master
Choose a base branch
from
refactor-collapsible-logic
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- The
showBadge@input onSharedFilterComponentis no longer used (badge visibility is now derived fromcollapsible/collapsed), so consider either removing the input or wiring it intoshouldShowBadgeto avoid dead or misleading API surface. - The new
collapse-togglebutton inshared-filterlacks accessibility attributes; consider adding at leastaria-labelandaria-expanded(and optionallyaria-controls) so screen readers can correctly announce the collapsible state of the filter.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `showBadge` @Input on `SharedFilterComponent` is no longer used (badge visibility is now derived from `collapsible`/`collapsed`), so consider either removing the input or wiring it into `shouldShowBadge` to avoid dead or misleading API surface.
- The new `collapse-toggle` button in `shared-filter` lacks accessibility attributes; consider adding at least `aria-label` and `aria-expanded` (and optionally `aria-controls`) so screen readers can correctly announce the collapsible state of the filter.
## Individual Comments
### Comment 1
<location> `src/app/datasets/datasets-filter/datasets-filter.component.html:29-33` </location>
<code_context>
- class="collapsible-filter-wrapper"
- [class.collapsed]="!expandedFilters[filter.key]"
- >
- <shared-filter
- [key]="filter.key"
- [label]="filter.label"
</code_context>
<issue_to_address>
**issue (bug_risk):** Dropping the `filter.enabled` condition means disabled filters will now still render.
Previously, checkboxes used `*ngIf="filter.type === 'checkbox' && filter.enabled"` and other filters used `*ngIf="filter.type !== 'checkbox' && filter.enabled"`, so disabled filters never rendered. After the refactor, `shared-filter` is created for every entry in `filtersList`, regardless of `filter.enabled`.
Unless `filtersList` is already restricted to enabled filters, this will surface filters that were previously hidden (same in `proposal-side-filter.component.html`). To keep the old behavior, either add `*ngIf="filter.enabled"` to `shared-filter` or filter out disabled items when constructing `filtersList`.
</issue_to_address>
### Comment 2
<location> `src/app/shared/modules/shared-filter/shared-filter.component.html:92-98` </location>
<code_context>
<ng-template #noItems>
<div class="empty-text">No options found</div>
</ng-template>
+ <button
+ *ngIf="collapsible"
+ class="collapse-toggle"
+ type="button"
+ (click)="toggleCollapse()"
+ >
+ <mat-icon>{{ collapsed ? "expand_more" : "expand_less" }}</mat-icon>
+ </button>
</div>
</code_context>
<issue_to_address>
**suggestion (bug_risk):** The collapse/expand button lacks an accessible label, which can hinder screen-reader users.
Since the button has only an icon and no text or ARIA attribute, screen readers will announce it as an unlabeled button.
Please add an accessible name, e.g. `aria-label="Toggle filter"` or bind a localized label such as `[attr.aria-label]="collapsed ? 'Expand filter' : 'Collapse filter' | translate"`, following your existing i18n pattern.
Suggested implementation:
```
<button
*ngIf="collapsible"
class="collapse-toggle"
type="button"
(click)="toggleCollapse()"
[attr.aria-label]="(collapsed ? 'shared.filters.expand' : 'shared.filters.collapse') | translate: localization"
>
<mat-icon>{{ collapsed ? "expand_more" : "expand_less" }}</mat-icon>
</button>
```
1. Ensure that translation keys like `shared.filters.expand` and `shared.filters.collapse` exist in your i18n files and resolve to something like "Expand filter" / "Collapse filter".
2. If your project uses a different key namespace, adjust the string literals to match the existing pattern (e.g. `filters.expand`, `filters.collapse`, etc.).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR moves collapsible logic for checkbox filters into shared-filter component. Parent components now only set
[collapsible].Motivation
Background on use case, changes needed
Fixes:
Please provide a list of the fixes implemented in this PR
Changes:
Please provide a list of the changes implemented by this PR
Tests included
Documentation
official documentation info
If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included
Backend version
Summary by Sourcery
Centralize checkbox filter collapsible behavior within the shared-filter component and simplify parent filter components to configure collapsibility via an input flag.
Enhancements: