Skip to content

Conversation

@geetxnshgoyal
Copy link

Description

This PR fixes a bug where autocomplete filters (Projects, Packages, Creators, Reviewers, Staging Projects, and Priorities) were showing empty checkboxes after clicking the magnifier button to submit a search.

Problem

When using autocomplete filters on the requests page:

  1. User types a value in an autocomplete field (e.g., Project name)
  2. User clicks the magnifier (🔍) button to submit
  3. Filter dropdown shows the selected value
  4. User clicks magnifier again (with or without typing a new value)
  5. Bug: Empty checkboxes appear in the filter dropdown

This happened because when the form was submitted, empty string values were being added to the params array and stored in @selected_filter without being cleaned up.

Solution

Modified Webui::RequestsFilter concern to use .compact_blank when assigning filter parameters to @selected_filter, ensuring empty strings are removed before rendering checkboxes in the view.

Changed methods:

  • filter_creators
  • filter_priorities
  • filter_staging_projects
  • filter_reviewers
  • filter_project_names
  • filter_package_names

This brings all filter methods in line with the filter_labels method, which was already correctly using compact_blank.

Testing

Added comprehensive tests in spec/controllers/webui/users/bs_requests_controller_spec.rb to verify:

  • Empty strings in filter parameters are properly removed
  • Valid filter values continue to work correctly
  • @selected_filter hash doesn't contain empty strings
  • All 6 affected filters behave consistently

Verification Steps

  1. Navigate to a requests page with filters (e.g., /my/requests)
  2. Open the "Projects" filter dropdown
  3. Type a project name in the search box
  4. Click the magnifier (🔍) button
  5. Open the Projects filter dropdown again
  6. Click the magnifier button again (with empty search or new value)
  7. Open the Projects filter dropdown
  8. Expected: Only valid project names appear as checkboxes (no empty checkboxes)
  9. Repeat for Packages, Creators, Reviewers, Staging Projects, and Priorities filters

Files Changed

  • app/controllers/concerns/webui/requests_filter.rb - Added .compact_blank to 6 filter methods
  • spec/controllers/webui/users/bs_requests_controller_spec.rb - Added tests for empty value handling

Related Issues

Fixes #18826

When clicking the magnifier button after filtering by Projects, Packages,
Creators, Reviewers, Staging Projects, or Priorities, empty values were
being added to the selected_filter arrays. This caused empty checkboxes
to appear in the filter dropdown.

The issue was that while the filter methods checked for blank values
using compact_blank before deciding whether to apply the filter, they
were assigning the raw params array to @selected_filter without cleaning
it first.

This commit ensures all filter parameter arrays use compact_blank when
assigning to @selected_filter, matching the pattern already correctly
implemented for the labels filter.

Fixes openSUSE#18826
@github-actions github-actions bot added the Frontend Things related to the OBS RoR app label Dec 1, 2025
@geetxnshgoyal
Copy link
Author

@hennevogel @eduardoj please look into it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend Things related to the OBS RoR app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request index filter wrong behaviour

1 participant