Skip to content

Conversation

@frano-m
Copy link
Contributor

@frano-m frano-m commented Sep 5, 2025

Closes #778.

This pull request refactors the logic for building validated column filters in the CollectionSelector utility by introducing a new approach that ensures only filter combinations that match at least one row in the table are applied. The previous implementation, which filtered out invalid columns and values individually, has been replaced with a stricter validation that checks the overall combination of filter values for validity. Additionally, a new utility function for value conversion was added.

Key changes:

Column Filter Validation Logic:

  • Replaced the previous buildValidatedColumnFilters implementation with a new version that only applies preselected filters if at least one row in the table matches all filters (AND across columns, OR within a column). If no such row exists, no filters are applied. This ensures only valid filter combinations are used.

Utility Functions:

  • Added a new toStringArray utility function to consistently convert values to string arrays, improving type safety and code clarity.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where the ENA picker returned no results when pre-filters didn't match data by refactoring the column filter validation logic. The new approach validates the entire combination of filters rather than individual values, ensuring only filter combinations that match at least one table row are applied.

  • Replaced individual column/value validation with combination-based validation
  • Added utility function for consistent value-to-string-array conversion
  • Changed validation to only apply filters when at least one row matches all filter criteria

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


return columnFiltersState;
function toStringArray(value: unknown): string[] {
if (value == null) return [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Checking == is intentional here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOL, no. I let Windsurf write that function 😱 .

Copy link
Contributor

@MillenniumFalconMechanic MillenniumFalconMechanic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks F! Just one nit for you to review.


return columnFiltersState;
function toStringArray(value: unknown): string[] {
if (value == null) return [];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if (value == null) return [];
if (value === null) return [];

@MillenniumFalconMechanic MillenniumFalconMechanic merged commit 58b887a into main Sep 8, 2025
3 checks passed
@MillenniumFalconMechanic MillenniumFalconMechanic deleted the fran/778-ena-picker-results branch September 8, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

No results on ENA picker when pre filters do not match

4 participants