Skip to content

Commit

Permalink
Fix filter not working when more than one of the same
Browse files Browse the repository at this point in the history
  • Loading branch information
anmcgrath committed Oct 14, 2024
1 parent e0b1c5c commit 5dbbc7c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/BlazorDatasheet.Core/Data/Filter/ValueFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ namespace BlazorDatasheet.Core.Data.Filter;

public class ValueFilter : IFilter
{
private HashSet<CellValue> _excluded = new();
private HashSet<string> _excluded = new();

public IReadOnlyCollection<string> Excluded => _excluded;

public ValueFilter()
{
Expand All @@ -13,24 +15,24 @@ public ValueFilter()

public void Include(CellValue value)
{
_excluded.Remove(value);
_excluded.Remove(value.ToString());
IncludeAll = _excluded.Count == 0;
}

public void Exclude(CellValue value)
{
_excluded.Add(value);
_excluded.Add(value.ToString());
IncludeAll = _excluded.Count == 0;
}

public bool Includes(CellValue value)
{
return IncludeAll || !_excluded.Contains(value);
return IncludeAll || !_excluded.Contains(value.ToString());
}

public bool Match(CellValue cellValue)
{
return !_excluded.Contains(cellValue);
return !_excluded.Contains(cellValue.ToString());
}

public bool IncludeBlanks { get; set; } = true;
Expand All @@ -55,7 +57,8 @@ public bool IncludeAll
if (value)
_excluded.Clear();

IncludeBlanks = value;
if (value)
IncludeBlanks = value;
_includeAll = value;
}
}
Expand Down

0 comments on commit 5dbbc7c

Please sign in to comment.